// ==UserScript==
// @name           KOC Power Bot
// @version        AIO_20140505.1a
// @namespace      mat
// @homepage       http://userscripts.org/scripts/show/162501
// @description    Bot,tools and multi had a threesome, this is their child.
// @include        *.kingdomsofcamelot.com/*main_src.php*
// @include        *.kingdomsofcamelot.com/*platforms/kabam*
// @include        *apps.facebook.com/kingdomsofcamelot/*
// @include        *kabam.com/games/kingdoms-of-camelot/play*
// @include 	   *kabam.com/nl/games/kingdoms-of-camelot/*
// @include        *facebook.com/dialog/feed*
// @icon 	       http://nicodebelder.eu/koc/logo.png

// @grant       GM_getValue
// @grant       unsafeWindow
// @grant       GM_deleteValue
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_listValues
// @grant       GM_addStyle
// @grant       GM_xmlhttpRequest
// @grant       GM_log
// @grant       GM_registerMenuCommand

// ==/UserScript==


//	┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
//	│   								 │
//	│   It is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License:   │
//	│   http://creativecommons.org/licenses/by-nc-sa/3.0 													 │
//	└────────────────────────────────────────────────────────────────────────────────────────────────────────┘

//Fixed weird bug with koc game
if(window.self.location != window.top.location){
   try{
      if(window.self.location.href == window.parent.location.href) return; //If iframe source is same as the parent don't load script  
    } catch (e){
      //logit(inspect(e,2,1));
   }
}	

var Version = 'AIO_20140505.1';

// These switches are for testing, all should be set to false for released version:
var DEBUG_TRACE = false;
var DEBUG_SEARCH = false;
var DISABLE_BULKADD_LIST = false;
var ENABLE_GM_AJAX_TRACE = false;
var SEND_ALERT_AS_WHISPER = false;
// end test switches

if (typeof SOUND_FILES == 'undefined') var SOUND_FILES = new Object();
if (typeof SOUND_FILES.whisper == 'undefined'){
	SOUND_FILES.whisper = new Object();
	SOUND_FILES.whisper.MP3 = 'data:audio/mp3;base64,//uQZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAABPAABG1AAECQ0RERUYHCAgJCcqLS0x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FJKKbZijI2lpNRaa60VY2wsJZXWWmutGGOMaym1FmOsxRhjXEuppRhrLMYY43tqLcZYYzHGGJ9baimmXAsAMHlwAIBKsHGGlaSzwtHgQkNWAgC5AQAIQkoxxphjzjnnnHPOSaUYc8455yCEEEIIIZRKMeacc85BByGEEEIoGXPOOQchhBBCCCGEUFLqmHMOQgghhBBCCCGl1DnnIIQQQgghhBBCSqlzzkEIIYQQQgghhJRSCCGEEEIIIYQQQggppZRCCCGEEEIIIZQSUkophRBCCCWEEkoIJaSUUgohhBBCKaWEUkJJKaUUQgillFBKKaGUkFJKKaUQQiillFBKKSWllFJKJZRSSikllFBKSimllEoooZRQSimllJRSSimVUkopJZRSSgkppZRSSqmUUkoppZRSUkoppZRSKaWUUkoppaSUUkoppVJKKaWUEkpJKaWUUkqllFBKKaWUUlJKKaWUSgqllFJKKaUAAKADBwCAACMqLcROM648AkcUMkxAhYasBABSAQAAQiillFJKKTWMUUoppZRSihyklFJKKaWUUkoppZRSSimVUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKAcDdFw6APhM2rI5wUjQWWGjISgAgFQAAMIYxxphyzjmllHPOOQadlEgp5yB0TkopPYQQQgidhJR6ByGEEEIpKfUYQyghlJRS67GGTjoIpbTUaw8hhJRaaqn3HjKoKKWSUu89tVBSainG3ntLJbPSWmu9595LKinG2nrvObeSUkwtFgBgEuEAgLhgw+oIJ0VjgYWGrAIAYgAACEMMQkgppZRSSinGGGOMMcYYY4wxxhhjjDHGGGOMMQEAgAkOAAABVrArs7Rqo7ipk7zog8AndMRmZMilVMzkRNAjNdRiJdihFdzgBWChISsBADIAAMRRrDXGXitiGISSaiwNQYxBibllxijlJObWKaWUk1hTyJRSzFmKJXRMKUYpphJCxpSkGGOMKXTSWs49t1RKCwAAgCAAwECEzAQCBVBgIAMADhASpACAwgJDx3AREJBLyCgwKBwTzkmnDQBAECIzRCJiMUhMq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4FQweEIui5tYLrdoUvM86KzxxG8Y4/QdWkPXWKe52mep+7u9uZpriIBAAAtTpu4iDglIkGKZjEBaBExcXEBTQnFRFnIEBXSRExAiECMBiUqJi773hTl6ckJb+GtEKaXmp6aPCixZ3nF+hW7XpSmp6emo3zz2KPLac+Sb1N2UwzF9bHY2k2zqNo4nGF6m0kmplisFqvFxLCdzqGN1dlqaFv82PnlpO0gVhuHu3HMwZQBH9/2dvZ2vgxM/9PsbC2qrtXG1r+tjWf69+PAoYOZOjKVwfT68PpdRaK24danU9WJSf9T/E+2/zMmvEHPNKmHU1aRk7tPP930UydLtiynT1mdrRNmyKR/W0uOwWB7aorFLJn0b7XYOjVrOD2dQzt7p1o9WqwGTZ+w9T1tAjQlfFzJ5sQZMXXaXp1VLX45sLeMG8vJCeu2rYqkcKkxCoteHK/zhEPnwccyqROms+10tob4skTnKl0M9g78slGrnV92VrdXlbmu6Wxv58s50/Xx78dJe9++wqk/jhxz5FDsnPCXPzOba5j+vf6KYxqT63dra6xwHdcpyfG7hVtdNKnFcT2VyFHpuE6lHmq38Hrc4kqX66uq+/raUfor1ZWzdFj9/dvLraFR6bhFElkstVsvmlR5++Ik7PvL7XL/n57a/cqNM3m5Oq7fVUa4X3MLtzDuS73yuI51lP41r6z8Jf04FY9PB9ep+PLpw2d1Qe4rvu3wNTGWmE53bvOxjGFsKZZpFlPqMGHre6fleNiPzrZOd9psnVufTEw5NTkvnd3p22oxq9vwcd4+8XIfK258rFlfu4qtl1XbU5Nz76gmb/R1wufchvnWUydtTp/wJLZv236j1WbnugG9yZ5/an7qD9D6r9zkQfa+/z8TGQnDF1hLsDXrAB50+9j2HwiggWvQ7WPbfyCABq6EMEkiIKCYQAQkAAAEJAAAAAAAfj7JDba1LJl7/sqVYKOCfNKctPKRgXLrxy9P3jwp6i9PAGmhftebCsqlXPIBPvZdAgDA3EkZQAFHPoB8ZIB8AA==';
	SOUND_FILES.whisper.DEFAULT = '<span><object type="application/x-shockwave-flash" data="http://koc.god-like.org/power/swf/pdxminiplayer.swf" width="160" height="20"><param name="wmode" value="transparent" /><param name="movie" value="http://koc.god-like.org/power/swf/pdxminiplayer.swf" /><param name="flashvars" value="mp3=http://koc-power-tools.googlecode.com/svn/trunk/sounds/DoorBell.mp3&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>';
}
if (typeof SOUND_FILES.allianceattack == 'undefined'){
	SOUND_FILES.allianceattack = new Object();
	SOUND_FILES.allianceattack.MP3 = 'data:audio/mp3;base64,//OAxAAAAAAAAAAAAEluZm8AAAAPAAAAUQAAQ28AAwYJDA8PEhYZHBwfIiUpKSwvMjU4ODw/QkVFSEtPUlJVWFteXmFlaGtubnF0eHt7foGEh4eLjpGUlJeanqGkpKeqrbCwtLe6vb3Aw8fKys3Q09ba2t3g4+bm6e3w8/P2+fz/AAAAOUxBTUUzLjk3IAFuAAAAAC6QAAAUQCQGqCIAAEAAAELvFtoJFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/zgMQAJuG6vAVPQAEFnjylKf4eK9Xq+PhgOQbgRwAVgQwwzLZ733QXF3cXDsG4f276IKCiI/oQKClC4CgLA8FBQUFBQUFxcXFxcXPd6hERERHd3d3d0RERERD3d3d3cxAAAAAMPDw8PAAAAAAMPDw8PAAAAAAMPDw8eAAAAAAYeHh4eAAAAAIw8PDx4AAAABsPDw/2AAAd+YeePAAAAAEYeHh48AAAAAXAYDAYDAYDAYDAYDAYADAghAKJngZEAQGcEp4GrROB48I+BsTAyAP/84LEJzWjb1JflbMCG/AxFhK/AwlgRAKJaBhECB+BgNBYBhBAQBgEAIBhHAX/gYFgKBCJUDCgBgDA8EYEQE//AQDMBQIYGCkAIOD8F7wDgFgLAh//wCgDhtgZUBgEYboJAMBvAAwAkQv//+G6IuKoMvilyLA3kD3RriUw0IN5H3////iOR9DLCExARzRWpDhzhZxDSKizSaIsLO/////yZIqMqTRFhliZIqMqTRFhliZIqMqTRAhliZHNGVVFticUhU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GnYQKIecgdA5CKqlUCDkHoXMQSkmpeA46KSGUUkoqxXMQSgmhlJRaKy6GUkoopaTUUpExhFJKKSWl1ooxpoSQUkqptVaMMaGEVFJKKbZijI2lpNRaa60VY2wsJZXWWmutGGOMaym1FmOsxRhjXEuppRhrLMYY43tqLcZYYzHGGJ9baimmXAsAMHlwAIBKsHGGlaSzwtHgQkNWAgC5AQAIQkoxxphjzjnnnHPOSaUYc8455yCEEEIIIZRKMeacc85BByGEEEIoGXPOOQchhBBCCCGEUFLqmHMOQgghhBBCCCGl1DnnIIQQQgghhBBCSqlzzkEIIYQQQgghhJRSCCGEEEIIIYQQQggppZRCCCGEEEIIIZQSUkophRBCCCWEEkoIJaSUUgohhBBCKaWEUkJJKaUUQgillFBKKaGUkFJKKaUQQiillFBKKSWllFJKJZRSSikllFBKSimllEoooZRQSimllJRSSimVUkopJZRSSgkppZRSSqmUUkoppZRSUkoppZRSKaWUUkoppaSUUkoppVJKKaWUEkpJKaWUUkqllFBKKaWUUlJKKaWUSgqllFJKKaUAAKADBwCAACMqLcROM648AkcUMkxAhYasBABSAQAAQiillFJKKTWMUUoppZRSihyklFJKKaWUUkoppZRSSimVUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKAcDdFw6APhM2rI5wUjQWWGjISgAgFQAAMIYxxphyzjmllHPOOQadlEgp5yB0TkopPYQQQgidhJR6ByGEEEIpKfUYQyghlJRS67GGTjoIpbTUaw8hhJRaaqn3HjKoKKWSUu89tVBSainG3ntLJbPSWmu9595LKinG2nrvObeSUkwtFgBgEuEAgLhgw+oIJ0VjgYWGrAIAYgAACEMMQkgppZRSSinGGGOMMcYYY4wxxhhjjDHGGGOMMQEAgAkOAAABVrArs7Rqo7ipk7zog8AndMRmZMilVMzkRNAjNdRiJdihFdzgBWChISsBADIAAMRRrDXGXitiGISSaiwNQYxBibllxijlJObWKaWUk1hTyJRSzFmKJXRM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ZS4kBIVBU0RUTFRAS0QCkTFBTQtIgCYEKGYmJgQlKiIkFBiNCVKC8VFxMXEhJgWq2EKisWhI4d2VgxbO1sDFbU4dGBFHNrYOnDMRhHTzjFHVtOBYw6sWOxtrAIgKmBYLVaLaZgCWByzszUwLaqGiWFi2GKYaufQTk0bW4utna3FNKwWExGrAyccd8JxJxyYaqgaKqaNvY1VVAx5ffj0mOvDp2MmoBv7zRXm8elxcXx6XOQapiiioojVzqGdFcfruB7XMYE5Xh8+HVyP18GEOa7jOl4fPn349OF1XMd1vB6vYFrs7eztrIaqYRoqpo29A3sbUxTUsFpMwzSsNvZ2VhGrja3FFOa4jiGvD58+vMJ1XMeQ6/F6DEAg1+N1MMfM49OHVVBRMUXVYu/AMUf2FtQwRUVFRRHX49OH1zEAAOtrsR8M5Hp8+vB6XGEy0OstUqfTGT4n9NSECSuF0fvwOSQAnE4YGil84XM6nU4CPXWGL3xET0c/dLvdLox+34gUvvA5nU7AO51Oh8Too9Hv9wPQul26EYAWAQ==';
	SOUND_FILES.allianceattack.DEFAULT = '<span><object type="application/x-shockwave-flash" data="http://koc.god-like.org/power/swf/pdxminiplayer.swf" width="160" height="20"><param name="wmode" value="transparent" /><param name="movie" value="http://koc.god-like.org/power/swf/pdxminiplayer.swf" /><param name="flashvars" value="mp3=http://koc-power-tools.googlecode.com/svn/trunk/sounds/AllianceAttack.mp3&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>';
}
if (typeof SOUND_FILES.alert == 'undefined'){
	SOUND_FILES.alert = new Object();
	SOUND_FILES.alert.OGG = 'data:audio/ogg;base64,T2dnUwACAAAAAAAAAAAAAAAAAAAAAFwISF0BHgF2b3JiaXMAAAAAAkSsAAD/////AO4CAP////+4AU9nZ1MAAAAAAAAAAAAAAAAAAAEAAAA3gACkEFH//////////////////3EDdm9yYmlzKgAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAwMzI1IChFdmVyeXdoZXJlKQEAAAATAAAAZW5jb2Rlcj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ZTWWosxSqlzSq3FGGOUUveUWoux1iildDLGGGOtzTnnZIwxxloLAEBocAAAO7BhdYSTorHAQkNWAgB5AAAIQkoxxhhjECGlGGPMMYeQUowxxhhUijHGHGMOQsgYY4wxByFkjDHnnIMQMsYYY85BCJ1zjjHnIITQOceYcxBC55xjzDkIoXOMMeacAACgAgcAgAAbRTYnGAkqNGQlABAOAAAYw5hzjDkGnYQKIecgdA5CKqlUCDkHoXMQSkmpeA46KSGUUkoqxXMQSgmhlJRaKy6GUkoopaTUUpExhFJKKSWl1ooxpoSQUkqptVaMMaGEVFJKKbZijI2lpNRaa60VY2wsJZXWWmutGGOMaym1FmOsxRhjXEuppRhrLMYY43tqLcZYYzHGGJ9baimmXAsAMHlwAIBKsHGGlaSzwtHgQkNWAgC5AQAIQkoxxphjzjnnnHPOSaUYc8455yCEEEIIIZRKMeacc85BByGEEEIoGXPOOQchhBBCCCGEUFLqmHMOQgghhBBCCCGl1DnnIIQQQgghhBBCSqlzzkEIIYQQQgghhJRSCCGEEEIIIYQQQggppZRCCCGEEEIIIZQSUkophRBCCCWEEkoIJaSUUgohhBBCKaWEUkJJKaUUQgillFBKKaGUkFJKKaUQQiillFBKKSWllFJKJZRSSikllFBKSimllEoooZRQSimllJRSSimVUkopJZRSSgkppZRSSqmUUkoppZRSUkoppZRSKaWUUkoppaSUUkoppVJKKaWUEkpJKaWUUkqllFBKKaWUUlJKKaWUSgqllFJKKaUAAKADBwCAACMqLcROM648AkcUMkxAhYasBABSAQAAQiillFJKKTWMUUoppZRSihyklFJKKaWUUkoppZRSSimVUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKAcDdFw6APhM2rI5wUjQWWGjISgAgFQAAMIYxxphyzjmllHPOOQadlEgp5yB0TkopPYQQQgidhJR6ByGEEEIpKfUYQyghlJRS67GGTjoIpbTUaw8hhJRaaqn3HjKoKKWSUu89tVBSainG3ntLJbPS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Jy77od152/u7GyargpSVaNxDD+bB3KaTv/ZgG5tF6j879nNz43pzUZf742FO3GeTmVp7ycRB1Snz41UTeazhNWdWqaNrZ2/vjtKzDESNMonxjqOWcap0wYq2sOx0dP7svgI2d/747DBJoTJ5866NHf67ymnOo4f7Z6hpz+zxM+v/F1NAqmZby+jnwZselhueGbb7f5mfrkWpfPxyDTn2WT801XeMPhGoefJ0bc+Hq5Ou+vVndS/8uv/WDuUfH15f9tf1485eV9SVk28xoZRva9fH4x9/Lk5zBfx4FNuOZ+3ufPYQ6P6+P271U6ZRSt17o+Suvy//7x7XLYUev0wdsFx1CUGvJynvv/EMluprgGbKn3RrzJP6NRSQBHWU76fFaTxia2AA==';
	SOUND_FILES.alert.DEFAULT = '<span><object type="application/x-shockwave-flash" data="http://koc.god-like.org/power/swf/pdxminiplayer.swf" width="160" height="20"><param name="wmode" value="transparent" /><param name="movie" value="http://koc.god-like.org/power/swf/pdxminiplayer.swf" /><param name="flashvars" value="mp3=http://sfx.god-like.info/alert.mp3&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>';
}
  

var DEFAULT_ALERT_SOUND_URL = 'http://koc-power-bot.googlecode.com/svn/trunk/RedAlert.mp3';
var SWF_PLAYER_URL = 'http://koc-power-bot.googlecode.com/svn/trunk/alarmplayer.swf';

var URL_CASTLE_BUT = "";
var URL_CASTLE_BUT_SEL = "";
var URL_PROVINCE_MAP = "%2F%2F%2F%2Ff%2F%2F%2Fv%2F8%2Ff3%2F%2Ff39%2Ff37%2F%2F%2Fpe%2F39%2F%2F%2FnO%2F37%2F%2F%2FlPf%2FnPf%2FlPHv9%2B%2Fv7%2F%2F3lO%2Fv5ubv7%2Ff3lPf3jO%2Fm7%2B%2F3jO%2F0lPfvlObm7%2Bb3jObm5u%2FvjN7m5ubvlObvjN7e5t3whN7e3ubmjObmhNbe1tbb3t7mjN7mhNbmhNbW1t7ehM7W1tTfe9TchM7O1s7OztbWe8XOzsXOxc7We8XWesXFzsXFxc7Oe73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UHYr7ybBEqIQdP%2B%2FUALn13NcVZ8dW6iDpRNy2lQbgAFsvb6Ua5OotLvwigdwMlSNvTvH5xOjIYR4nTvs4dejLAUzXjh289t3bK3pvPV43d%2FTUr1OsPfG9c%2FXzv5uMDxP49%2Fu1AwIAOw%3D%3D";
var provMapCoords = {imgWidth:710, imgHeight:708, mapWidth:670, mapHeight:670, leftMargin:31, topMargin:19};  
var CHAT_BG_IMAGE = "%2F%2F5v%2F%2F1v%2F33v%2F31vf35v%2F3zvf33v%2F3xff31vf3zv%2Fv3u%2F33v%2Fv1v%2Fvzvfv1vfvzvfvxffvvffmzu%2Fmvebmvffere%2Feve%2Fete%2Fere%2Fepebevebeteberd7evd7ete%2FWpebWtd7Wtd7Wrd7WpdbWrd7Ord7OpdbOrdbOpdbFpc7FtdbFnM7FnMXFrc7FlM69rc69nM69lM69jMW9nMW9lMW9jL29nL29lM61jMW1nMW1lMW1jL21nMW1hL21lL21jMWtlLW1lL2tnL2tlL2thL2te7WthL2le72lc7WlhL2la7Wle7Wlc7Wla62le62lc7Wce7Wcc62chLWca6WcjK2cc6WchK2ca62cY6Wcc6Wca6WUhK2Ua6WUa6WUY5yUY5yMa5yMY5yMWpSMa5SMY5SMWoyMY5SEa5SEY4SEe4yEY4yEWoyEUpx7Uox7Wox7UoR7WoR7UoRzUntzY4RzSntzUntzSnNzSntrSmtrY3NrSmtjOhlrzmNaSjpjhBljxRljvRljtRlarRlapRlSnBlSlBlKjBlKhBlKexlCexlCcxlCa0o6CCE6Uhk6Yxk6WkopAEIpADopABAxQjEpEDEpCCEpMRkpMTohADEhACkhCDEZACkZACEZCCEZACEQABkQABkIABAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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qWvWqM4UpKE%2BK1a569asZbacuachVsJr1rGgtqTtlSFZNuPWtcI2rXOdK17ra9a54zate98rXvvr1r4ANrGAHS9jCGvatYmWrBw%2FL2MY69rGQjaxkJ0vZyro1C0Uo5mIty9nOevazoA2taAOLWc32YbSoTa1qV8va1t61CkdoqGv%2BZ0vb2tr2toGFrWxxy9ve%2Bva3qdUtUU8L3OIa97jIHaxwXZnc5jr3uc9d7hihS93qWre20t3sdbfL3e5aVrcx9SAlxkve8pr3vOhNr3rXy972uve98I2vfOdL3%2Fra9774za9%2B90veKhQBEuHVA38HTOACG%2FjACE6wghfM4PFC4QgAdqSAG0zhClv4whjOsIbt%2B%2BAIj3HDIA6xiEdM4hKztwpIgIQKXNmISbj4xTCOsYxnTOMa2%2FjGOM6xjnfM4x77%2BMdADrKQh0zkIhf5EpagxBVSTNQ88OHJUI6ylKdM5Spb%2BcpYzrKWt8zlLnv5y2AOs5jHTOYym%2FnMUH5Cilv%2BsIAF5CEPf4iznOdM5zrb%2Bc54zrOe98znPvv5z4AOtKAHTehCG%2FrQiE60nO0CCRsgwM1%2BAISkJ03pSlv60pjOtKY3zelOe%2FrToA61qEdN6lKb%2BtSoTrWqJ22FJEBiBgPoYKRXTeta2%2FrWuM61rnfN614DwgpLgAQMBCDrQBj72MhOtrKXzexmO%2FvZ0I62tKdN7Wpb%2B9rYzra2t83tbnv72A2BxE7T4AdBmPvc6E63utfN7na7%2B93wjre8503vetv73vjOt773ze9%2B%2B%2FvcRoiCh8n974Ib%2FOAIT7jCF87whjvc3EaA8LjzMIiKW%2FziGM%2B4xjfO8Y57%2FOMgD7nIR07%2F8pKb%2FOQoT7nKV87ylls8CRIXYxryQIia2%2FzmOM%2B5znfO8577%2FOdAD7rQh070ohv96EhPutKXzvSm2zzi4pY5zZ1O9apb%2FepYz7rWt871rhPCCEyWeiHGTvaym%2F3saE%2B72tfO9ra7%2Fe1wj7vc5073utv97njPu973TnawR10BMzeE4AdP%2BMIb%2FvCIT7ziF8%2F4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MDYjgVZjz3ZkBXZEzDZjIXYlDVZFkBZj2UBmk0BmqVZkGWBnG1ZnkWBFViBjP1ZoR3ZkSXYFWCBo%2F3ZjhVapm1ap3Xam41apG3am12BGNiBGtiBHTjaGXCCJAABH2CEURgFYj2AwjICGmCBGVBbGqCBGYABuIWBGJjbuW1bu73ZGUhbFoABqbVbv50BwM1btw1cwSXcuIUBv01cxU3cGsharM3aHugBIpjcHtDayn1cv%2FUBzfWBHfgBzyUCz%2FVcrd2BySUCIzAC0C3d0j1dI%2FjcH1DdJYhd1k0C1P9VXda9XdpFXSOIXd693SXI3dPlXd6lXeEt3iW4Xd8V3t29XSdoXuSd3SQwXuXd3eMN3ue93uuN3SLY3uKNXtml3iUogvAN3u%2BV3uIVX%2FE93iIwgvU13fXdXvgVXid4Ai3ogi8Igy5Ygh8Agx9omT4IhU8YBVEQugDwq%2BbNAgRO4CyogirIAi3QAgZ%2B4C54YC1QYASm4ApG4Al%2BYAvuYA%2F%2BYAZWYAzuAhIm4REmYS%2FQAi8IAzEQgzB4YS%2BI4RKeYfv9Ahv%2BAjLIYR0mgxfu4TAggzIoAx8eYiJ%2B4RwO4iDeYSLO4R5mYiPeYR5u4ij%2B4SLugiLGXxrO4hKuXy3eYAxTzuAvpuAJXmAHDmEEroLmfYInaF42doIqUOM1ZmM4nmMGZmMGvuM7hmM3ZmA1xmM%2F5uM5juM1ll8n4F04jmArLoM1YIMyWGMYGIAf6NKxFQVRCAgAOw%3D%3D";


var JSON;if(!JSON){JSON={};}(function(){"use strict";function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
var JSON2 = JSON;

var RPM = 0;
var RPMtime = unixTime();

//Kabams new cheat detector
unsafeWindow.arthurCheck = function (a) {
  var b = false;
  for (var c = 0; c < a.length; c++) if ($(unescape(a[c]))) {b = true;break}
  if (b) {
  	//alert(b);
  	unsafeWindow.AjaxCall.gPostRequest("ajax/funnelTracking.php", {action: 1300,serverId: unsafeWindow.g_server,uid: unsafeWindow.moderators[Math.floor((Math.random()*unsafeWindow.moderators.length))]})
  }
};

var Options = {

  srcSortBy    : 'level',
  srcMinLevel  : 1,
  srcMaxLevel  : 7,
  wildType     : 1,
  unownedOnly  : true,
  mistedOnly   : true,
  hostileOnly  : false,  
  friendlyOnly : false,  
  alliedOnly   : false,  
  unalliedOnly : false,  
  neutralOnly  : false,  
  srcAll       : true,  
  srcScoutAmt  : 1,
  minmight     : 1,
  srcdisttype  : 'square',
  pbWinIsOpen  : false,
  pbWinDrag    : true,
  pbWinPos     : {},
  pbTrackOpen  : true,
  pbKillFairie : false,
  pbGoldHappy  : 95,
  pbGoldEnable : false,
  pbEveryEnable: false,
  pbEveryMins  : 30,
  pbChatOnRight: false,
  pbWideMap    : false,
  pbFoodAlert  : false,
  pbSummonToggle : false,
  pbAntiCheat: false,
  alertConfig  : {aChat:false, aPrefix:'** I\'m being attacked! **', scouting:false, wilds:false, defend:true, minTroops:10000, spamLimit:10, lastAttack:0, barbautoswitch:false, raidautoswitch: {}, alertTR:false, alertTRset:1,email:false},
  alertSound   : {enabled:false, soundUrl:DEFAULT_ALERT_SOUND_URL, repeat:true, playLength:20, repeatDelay:0.5, volume:100, alarmActive:false, expireTime:0},
  spamconfig   : {aspam:false, spamvert:'Join my Alliance!!', spammins:'30', atime:2 , spamstate:'a'},
  giftDomains  : {valid:false, list:{}},
  celltext     : {atext:false, provider:0, num1:"000", num2:"000", num3:"0000"},
  giftDelete   : 'e',
  currentTab   : null,
  TournoiLigne : 25,
  hideOnGoto   : true,
  transportinterval : 60,
  minwagons    : 100,
  lasttransport: 0,
  lastCityTransport : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  reassigninterval: 60,
  lastreassign : 0,
  HelpRequest  : false,
  DeleteRequest: false,
  MapShowExtra : false,
  RaidRunning  : true,
  RaidReset    : 0,
  DeleteMsg	   : false,
  DeleteMsgs0  : false,
  DeleteMsgs1  : false,
  DeleteMsgs2  : false,
  DeleteMsgs3  : false,
  Foodstatus   : {1:0,2:0,3:0,4:0,5:0,6:0,7:0},
  Creststatus  : {1101:0,1102:0,1103:0,1104:0,1105:0,1106:0,1107:0,1108:0,1109:0,1110:0,1111:0,1112:0, 13:0, 14:0, 15:0, 16:0, 17:0,1113:0,1114:0,1115:0},
  LastReport   : 0,
  LastCrestReport   : 0,
  MsgInterval  : 1,
  CrestMsgInterval  : 1,
  foodreport   : false,
  crestreport  : true,
  Crest1Count  : 0,                            
  Crest2Count  : 0,                                                                            
  crestRunning   : false,    
  Crestinterval        : 5,        
  ThroneDeleteItems    :    false,
  ThroneDeleteLevel    :    0,
  throneSaveNum    :    10,
  throneDeletedNum : 0,
  RangeSaveModeSetting : 0,
  Opacity : 0.9,
  language : 'en',
  curMarchTab : "transport",
  ResponseSize:0,
  lastGiftSend:0,
  FoodAlertChecked:0,
  RPClip:1,
  SearchMightMin:0,
  SearchMightMax:9999,
  Authenticate:true,
  KMagicBox : false,
  sendGift:true,
  GiftSendTo: {},
  curOptTab : 'Options',
  curBuildTab : 'Build',
  chatEnhance : true,
  chatglobal : true,
  chatwhisper : true,
  chatbold : false,
  chatAttack : true,
  chatLeaders : true,
  rptType:'alliance',
  arAttacker:'Them',
  arTarget:'Them',
  arPageFrom : 1,
  arPageTo : 5,
  enableWhisperAlert : true,
  enableTowerAlert : true,
  ReturnToCity : null,
  watchdog: false,
  WatchdogInterval: 15,
  WatchDogFilter:true,
  MouseMove:0,
  PlayerFilter:[],
};

var GlobalOptions = {
  pbWatchdog   : false,
  pbWideScreen : true,
  pbWideScreenStyle : 'widescreen',
  autoPublishGamePopups : false,
  autoPublishPrivacySetting : 80,
  pbupdate : true,
  pbupdatebeta : 0,
  pbNoMoreKabam : false,
  escapeurl : null,
};

var CrestOptions = {
  Running   	: 	false,
  CrestCity 	: 	0,
  RoundOne  	: 	false,
  RoundTwo  	: 	true,
  lastRoundTwo 	: 	0,
  X				:	0,
  Y				:	0,
  R1ST			:	0,
  R1MM			:	0,
  R1Scout		:	0,
  R1Pike		:	0,
  R1Sword		:	0,
  R1Arch		:	0,
  R1LC			:	0,
  R1HC			:	0,
  R1SW			:	0,
  R1Ball		:	0,
  R1Ram			:	0,
  R1Cat			:	0,
  R2ST			:	0,
  R2MM			:	0,
  R2Scout		:	0,
  R2Pike		:	0,
  R2Sword		:	0,
  R2Arch		:	0,
  R2LC			:	0,
  R2HC			:	0,
  R2SW			:	0,
  R2Ball		:	0,
  R2Ram			:	0,
  R2Cat			:	0,
};

var TrainOptions = {
  Running    : false,
  Troops     : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  Threshold  : {1:500,2:500,3:500,4:500,5:500,6:500,7:500,8:500},
  Max        : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  Gamble     : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  Workers    : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  Item       : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  Keep       : {1:{Food:0,Wood:0,Stone:0,Ore:0},
                2:{Food:0,Wood:0,Stone:0,Ore:0},
				3:{Food:0,Wood:0,Stone:0,Ore:0},
				4:{Food:0,Wood:0,Stone:0,Ore:0},
				5:{Food:0,Wood:0,Stone:0,Ore:0},
				6:{Food:0,Wood:0,Stone:0,Ore:0},
				7:{Food:0,Wood:0,Stone:0,Ore:0},
				8:{Food:0,Wood:0,Stone:0,Ore:0}
			   },
  Enabled    : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},
  SelectMax  : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},
  Resource   : {1:true,2:true,3:true,4:true,5:true,6:true,7:true,8:true},
  UseIdlePop : {1:true,2:true,3:true,4:true,5:true,6:true,7:true,8:true},
  KillTroops : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false}, // mac mod
  UseHour : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false}, // mac mod
  UseHourGlasses : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false}, // mac mod
  CraftingRunning : false,
  CraftIntervallMin : 3,
  CraftingActif : {3000:false,3001:false,3002:false,3003:false,3004:false,3005:false,3006:false,3007:false,3008:false,3009:false,3010:false,3011:false},
  CraftingNb : {3000:0,3001:0,3002:0,3003:0,3004:0,3005:0,3006:0,3007:0,3008:0,3009:0,3010:0,3011:0},
  tr	:	false,
  tr2 : false,
  trset	:	0,
  trset2 : 0,
  DisUnt  :  1,  // mac mod
  actr:     false,
  actrset : 0,
  AsTroops     : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
  AsEnabled  : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},
  AsSelectMax  : {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},
  AsMax        : {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
};

var FarmOptions = {
	RallyClip: 0,
    Running: false,
    MinMight: 0,
    MaxMight: 999999999,
    Interval: 0,
    SendInterval: 10,
    MaxDistance: 20,
    Inactive:30,
	DeleteReports:false,
	Troops: {1: 0,2: 0,3: 0,4: 0,5: 0,6: 0,7: 0,8: 0,9: 0,10: 0,11: 0,12: 0,13: 0,14: 0,15: 0,16: 0},
	FarmNumber: {1: 0,2: 0,3: 0,4: 0,5: 0,6: 0,7: 0,8: 0},
    CityEnable: {1: true,2: true,3: true,4: true,5: true,6: true,7: true,8: true},
    CityLevel: {0: true,1: true,2: true,3: true,4: true,5: true,6: true,7: true,8: true,9: true,10: true,11: true,12: true},
    Diplomacy: {friendly: true,hostile: true,friendlyToThem: true,friendlyToYou: true,neutral:true,unallied:true},
    FarmMarches: [],
    farmMarches: {},
    Attacks:0,
	Checks:0,
};

var MarchOptions = {
	Queue: []
};

var AtkOptions = {
	Running:false,
	1:[],
	2:[],
	3:[],
	4:[],
	5:[],
	6:[],
	7:[],
	8:[]
};

var ThroneOptions = {
    Active:false,
    Interval:30,
    RepairTime:0,
	Tries:0,
    minStones : 5000,
	Good:0,
	Bad:0,
  testd: [],
	Items: [],
	SalvageQuality:0,
	saveXitems:0,
	thronekeep:1,
	Salvage:{},
	Salvage_fav:{},
	Salvage_slots:{},
	Salvage_Type:{},
	UseTokens: false,
	LLTlevel:5,
	LPSlevel:0,
	PresetName: {1: "Preset 1",2: "Preset 2",3: "Preset 3",4: "Preset 4",5: "Preset 5",6: "Preset 6",7: "Preset 7",8: "Preset 8"},
	Presets: 	{
				1:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				2:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				3:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				4:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				5:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				6:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				7:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0},
				8:{advisor:0,banner:0,chair:0,candelabrum:0,table:0,trophy:0,windows:0}
			},
};

var DFOptions = {
  LastSearch 			: 0,
  Running       		: false,
  DFFound 				: 0,
  DFFailedBog       	: 0,
  Levels    			: {1:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},2:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},3:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},4:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},5:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},6:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},7:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},8:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false}},
  Troops    			: {1:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},2:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},3:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},4:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},5:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},6:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},7:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},8:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},9:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},10:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0}},
  knightselector        : 0,
};
var mercOptions = {
  LastSearch 			: 0,
  Running       		: false,
  mercFound 				: 0,
  mercFailedBog       	: 0,
  Levels    			: {1:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},2:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},3:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},4:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},5:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},6:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},7:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},8:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false}},
  Troops    			: {1:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},2:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},3:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},4:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},5:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},6:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},7:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},8:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},9:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0},10:{1:0,2:0,3:0,4:0,5:0,6:0,7:0, 8:0,9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0, 16:0, 17:0}},
  knightselector        : 0,
};

var ApothecaryOptions = {
	Active : false,
	goldkeep : 0,
	city : {0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[]},
};

var MarchQueue = {
	1:[],
	2:[],
	3:[],
	4:[],
	5:[],
	6:[],
	7:[],
	8:[]
};

var Colors ={
	DarkRow        : '#eee',
	ButtonSelected : '#444444',
    ChatLeaders    : '#B6E7F2',
    ChatGlobal     : '#CCCCFF',
    OverviewDarkRow : '#f0f0f0',
	ChatAll        : '#99ccff',
	ChatAtt        : '#FF4D4D',
	ChatWhisper    : '#FF4D4D',
	ChatVC         : '#9ADE78',
	ChatChancy     : '#E9BEED',
	Opacity        : '0.9',

};

var ChatIcons = {
	ReqSend: 			0,
	fidCache: 			[],
};

var CraftOptions = {
	Running: 	false,
	City : 		{0:true,1:true,2:true,3:true,4:true,5:true,6:true,7:true},
	items: 		[],
	enabled: 	[],
	cap: 		[],
	until:		[],
};

var sacrifice = {
	1:[],
	2:[],
	3:[],
	4:[],
	5:[],
	6:[],
	7:[],
	8:[]
};


var ResetAll=false;
var deleting=false;
var Recall=[];
var WhatCity = 1;
var MarchesSend = 0;
var MarchesError = 0;
var MarchDelay = 5;
var MarchOffset = MarchDelay;
var Seconds = 0;

// Get element by id shortform with parent node option
function $(ID,root) {return (root||document).getElementById(ID);}

var nHtml={
  FindByXPath:function(obj,xpath,nodetype) {
	if(!nodetype) nodetype = XPathResult.FIRST_ORDERED_NODE_TYPE;	
	try {
		var q=document.evaluate(xpath,obj,null,nodetype,null);
	} catch(e) {
		GM_log('bad xpath:'+xpath);
	}
	if(nodetype == XPathResult.FIRST_ORDERED_NODE_TYPE){
		if(q && q.singleNodeValue) { return q.singleNodeValue; }
	}else{
		if(q){
			return q;
		}
	}
	return null;
  },
  
  ClickWin:function(win,obj,evtName) {
	var evt = win.document.createEvent("MouseEvents");
	evt.initMouseEvent(evtName, true, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
	return !obj.dispatchEvent(evt);
  },

  Click:function(obj) {
	return this.ClickWin(window,obj,'click');
  },
  
  ClickTimeout:function(obj,millisec) {
	window.setTimeout(function() {return nHtml.ClickWin(window,obj,'click');},millisec+Math.floor(Math.random()*500));
  },

  SetSelect:function(obj,v) {
	for(var o=0; o<obj.options.length; o++) if(v==obj.options[o].value) { obj.options[o].selected=true; return true; }
	return false;
  },
}

readGlobalOptions();
GlobalOptions.pbWideScreen = true;

if (document.URL.search(/apps.facebook.com\/kingdomsofcamelot/i) >= 0){
	setTimeout(function() {
		var url=document.URL;
		var what = /s=([0-9]+)/i.exec(url);
		if (what) unsafeWindow.window.document.title="KOC "+what[1];		
	}, 10000)
	facebookInstance();
	HandlePublishPopup();
	return;
}

if (document.URL.search(/kabam.com\/games\/kingdoms-of-camelot\/play/i) >= 0){kabamStandAlone ();return;}
if (document.URL.search(/kabam.com\/nl\/games\/kingdoms-of-camelot\/play/i) >= 0){kabamStandAlone ();return;}

if (document.URL.search(/facebook.com/i) >= 0){
	if(document.URL.search(/connect\/uiserver.php/i) >= 0 || document.URL.search(/serverfbml/i) >= 0 || document.URL.search(/dialog\/stream.publish/i) >= 0 || document.URL.search(/dialog\/apprequests/i) >= 0 || document.URL.search(/dialog\/feed/i) >= 0) HandlePublishPopup();
  	return;
}

if (document.URL.search(/kingdomsofcamelot.com/i) >= 0) kocWideScreen ();

function kocWideScreen(){
  function setWideFb (){
	var kocFrame = '';
	try{
		kocFrame = parent.document.getElementById('kocIframes1');
	} catch (e){
		logit("kocWideScreen "+e);
		kocFame = document.getElementById("kocIframes1");
	}
	if (!kocFrame){
	  setTimeout (setWideFb, 1000);
	  return;
	}
	kocFrame.style.width = '100%';
	var style = document.createElement('style')
	style.innerHTML = 'body {margin:0; width:100%; !important;}';
	kocFrame.parentNode.appendChild(style);
  }
  kocWatchdog ();
  if (GlobalOptions.pbWideScreen)
		setWideFb();
}

var aj2 = function(c, d, b, a) {
    if (d.ctrl && d.ctrl == "Tracking") return;
    else unsafeWindow.AjaxCall.gAjaxRequest(c, d, b, a, "post");    
}

if(unsafeWindow.AjaxCall) unsafeWindow.AjaxCall.gPostRequest = aj2

/***  Run only in "apps.facebook.com" instance ... ***/
function facebookInstance (){
  function setWide (){
	var iFrame = document.getElementById('iframe_canvas');
	if (!iFrame){
	  setTimeout (setWide, 1000);
	  return;
	}
	iFrame.style.width = '100%';

	while ( (iFrame=iFrame.parentNode) != null)
	  if (iFrame.tagName=='DIV')
		iFrame.style.width = '100%';
	document.getElementById('globalContainer').style.left = '0px';
    try{    
      document.getElementById('rightCol').parentNode.removeChild(document.getElementById('rightCol'));
      document.getElementById('leftColContainer').parentNode.removeChild(document.getElementById('leftColContainer'));
    } catch (e){
      // toolkit may have removed them already!
    }
    var e = document.getElementById('mainContainer');
	if(e){
		if (GlobalOptions.pbWideScreenStyle=="normal") e.parentNode.style.minWidth = '100%';
		if (GlobalOptions.pbWideScreenStyle=="wide") e.parentNode.style.width = '100%';
		if (GlobalOptions.pbWideScreenStyle=="ultra") e.parentNode.style.width = '100%';
		for(i=0; i<e.childNodes.length; i++){
			if(e.childNodes[i].id == 'contentCol'){
				e.childNodes[i].style.margin = '0px';
				e.childNodes[i].style.paddingTop = '5px';
				break;
			}
		}
	}
	var e = document.getElementById('pageHead');
	if(e){
		e.style.width = '80%';
		e.style.margin = '0 10%';
	}
	var e = document.getElementById('bottomContent');
	if(e){
		e.style.padding = "0px 0px 12px 0px";
	}
    
  }
  facebookWatchdog();
  if (GlobalOptions.pbWideScreen)
    setWide();
}

function kabamStandAlone (){
  function setWide (){
	var iFrames = $('game_frame');
	if (!iFrames){
	  setTimeout (setWide, 1000);
	  return;
	}
	
	iFrames.style.width = '100%';
	while ( (iFrames=iFrames.parentNode) != null && iFrames.tagName !== "BODY") {
		if (GlobalOptions.pbWideScreenStyle=="normal") iFrames.style.width = '100%';
		if (GlobalOptions.pbWideScreenStyle=="wide") iFrames.style.width = '1520px';
		if (GlobalOptions.pbWideScreenStyle=="ultra") iFrames.style.width = '1900px'
	}
	try{    
      document.getElementById('promo-sidebar').parentNode.removeChild(document.getElementById('promo-sidebar'));
    } catch (e){
      logit("Failed to remove sidebar "+e);
    }
  }

  function sendmeaway (){
	var serverID = /s=([0-9]+)/im.exec (document.location.href);
	var sr = /value="(.*?)"/im.exec ($("post_form").innerHTML);
	var goto = $("post_form").action+(serverID?"?s="+serverID[1]:'');
	var t = '<FORM target="_top" action="'+ goto +'" method=post><INPUT id=xxxpbutExplode type=submit class=pbButton value=RELOAD><INPUT type=hidden name=signed_request value="'+ sr[1] +'" /><INPUT type=hidden name=platform_req value=A /></form>';
	var e = document.createElement ('div');
	e.innerHTML = t;
	document.body.appendChild (e);
	setTimeout (function (){document.getElementById('xxxpbutExplode').click();}, 0);
  }
  if (GlobalOptions.pbWideScreen) setWide();
  if(GlobalOptions.pbNoMoreKabam) sendmeaway();
}

function HandlePublishPopup() {
	if(GlobalOptions.autoPublishGamePopups){
		var FBInputForm = document.getElementById('uiserver_form');
		//logit(FBInputForm)
		if(FBInputForm){
			var channel_input = nHtml.FindByXPath(FBInputForm,".//input[contains(@name,'channel')]");
			if(channel_input){
				var current_channel_url = channel_input.value;
				if (current_channel_url.match(/(http|https):\/\/(.*?)\.kingdomsofcamelot\.com(.*?)/i)) {
					var publish_button = nHtml.FindByXPath(FBInputForm,".//input[@type='submit' and contains(@name,'cancel')]");
					if(publish_button) nHtml.Click(publish_button);
					
				}
			}		
		}
		setTimeout(HandlePublishPopup, 1000);
	}
}

var Cities = {};
var Seed = unsafeWindow.seed;
var Tabs = {};
var pbButtons = {};
var mainPop;
var pbStartupTimer = null;
var pbPopUpTopClass = 'pbPopTop';
var firefoxVersion = getFirefoxVersion();
var TrainCity = 0;
var CM = unsafeWindow.cm;

function pbStartup (){
	clearTimeout (pbStartupTimer);
	if (unsafeWindow.pbLoaded) return;
	var metc = getClientCoords(document.getElementById('main_engagement_tabs'));
	if (metc.width==null || metc.width==0){
		pbStartupTimer = setTimeout (pbStartup, 1000);
		return;
	}
	unsafeWindow.pbLoaded = true;
	Seed = unsafeWindow.seed;
	readOptions();
    readColors();
    
   var styles = '.xtab {padding-right: 5px; border:none; background:none; white-space:nowrap;}\
    .xtabBR {padding-right: 5px; border:none; background:none;}\
    table.pbTab tr td {border:none; background:none; white-space:nowrap; padding:0px}\
    table.Throne {background-color:#FFFFE3; white-space:nowrap; padding:0px; border-style:solid; border-color:darkgrey; width:250px; max-width:250px; text-wrap:normal;word-wrap:break-word}\
    table.Throne tr td {background:none; white-space:nowrap; padding:0px; border-style:none;}\
    table.ThroneEQ {background-color:#FFFFE3; white-space:nowrap; padding:0px; border-style:solid; border-color:lightred; width:250px; max-width:250px; text-wrap:normal;word-wrap:break-word}\
    table.ThroneEQ tr td {background:none; white-space:nowrap; padding:0px; border-style:none}\
    table.ptNoPad tr td {border:none; background:none; white-space:nowrap; padding:0px}\
    table.ptTabPad tr td {border:none; background:none; white-space:nowrap; padding: 2px 4px 2px 4px;}\
    table.ptTabPad tr td.ptentry {background-color:#FFEECC ; padding-left: 8px;}\
    .hostile td { background:red; }.friendly td{background:lightgreen; }.ally td{background:lightblue; }\
    table.pbTabPadNW tr td {border:none; background:none; white-space:nowrap; padding: 2px 4px 2px 8px;}\
    table.pbTabBR tr td {border:none; background:none;}\
    table.pbTabLined tr td {border:1px none none solid none; padding: 2px 5px; white-space:nowrap;}\
    table.pbOptions tr td {border:1px none none solid none; padding: 1px 3px; white-space:nowrap;}\
    table.pbSrchResults tr td {border:1px none none solid none; padding: 1px 3px; white-space:nowrap;}\
    table.pbTabSome tr td {border:none; background:none; padding: 1px 3px; white-space:nowrap;}\
    table.pbTabPad tr td { padding-left: 8px;}\
    .ptentry {padding: 7px; white-space:nowrap;}\
    .ptOddrow {background-color:#eee}\
    .pbDetLeft {padding:0 5px 0 0 !important; font-weight:bold; text-align:right}\
    .pbStat {border:1px solid; border-color:#000000; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff ; background-color:#357;  border-radius:5px;}\
    .pbStatOrange {border:1px solid; border-color:#000000; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff ; background-color:orange;  border-radius:5px;}\
    .pbStatRed {border:1px solid; border-color:#000000; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff ; background-color:red;  border-radius:5px;}\
    .pbentry {padding: 7px; white-space:nowrap;}\
    .ptChatAttack {color: #000; font-weight:bold; background-color:'+Colors.ChatAtt+'; }\
    .ptChatWhisper {font-weight:bold; color: '+Colors.ChatWhisper+';}\
    .ptChatAlliance {background-color: '+Colors.ChatAll+';}\
	.ptChatScripter {font-weight:bold; background-color:#D0F7A8;}\
    .ptChatGlobal {background-color:'+Colors.ChatGlobal+';}\
    .ptChatBold {font-weight:bold}\
    .ptChatGlobalAll {font-weight:bold;background-color:'+Colors.ChatGlobal+';}\
    .ptChatIcon {border: 1px inset black}\
    .ptChatCHAN {color:#000; background-color:'+Colors.ChatChancy+';}\
    .ptChatVICE {color:#000; background-color:'+Colors.ChatVC+';}\
	.ptChatOFFI {color:#000; background-color:'+Colors.ChatLeaders+';}\
    span.whiteOnRed {padding-left:3px; padding-right:3px; background-color:#700; color:white; font-weight:bold}\
    .castleBut {outline:0px; margin-left:0px; margin-right:0px; width:24px; height:26px; font-size:12px; font-weight:bold;}\
    .castleBut:hover {background-image:url("'+ URL_CASTLE_BUT_SEL +'")}\
    .castleButNon {background-image:url("'+ URL_CASTLE_BUT +'")}\
    .castleButSel {background-image:url("'+ URL_CASTLE_BUT_SEL +'")}\
    input.pbDefButOn {cursor:pointer; border:1px solid #45d183; box-shadow:inset 0px 1px 5px #3aef8b; border-radius:5px;}\
    input.pbDefButOff {cursor:pointer; border:1px solid #f61646; box-shadow:inset 0px 1px 5px #f6375f; border-radius:5px;}\
    input.pbSubtab {cursor:pointer; width:8em; margin-right:5px; border-radius:10px;}\
    input.pbSubtabSel {background-color:'+Colors.ButtonSelected+'; color:white; font-weight:bold; -moz-border-radius:5px; cursor:none !important}\
    a.ptButton20 {color:#ffff80}\
    a.ptButtonRed {color:#FA4848}\
    table.pbMainTab { empty-cells: show; margin-left: 5px; margin-top: 4px; padding: 1px;  padding-left:5px;}\
    table.pbMainTab tr td a {color:inherit }\
    table.pbMainTab tr td   {height:60%; empty-cells:show; padding: 0px 4px 0px 4px;  margin-top:5px; white-space:nowrap; border: 1px solid; border-style: none none solid none; border-radius:5px; }\
    table.pbMainTab tr td.spacer {padding: 0px 0px;}\
    table.pbMainTab tr td.notSel { color: #ffffff; font-size: 12px; font-weight:bold; border-radius: 10px; box-shadow: 0px 1px 3px #357544; text-shadow: -1px 1px 3px #666666; border: solid #615461 1px; background: -moz-linear-gradient(to top, #6ff28e, #196b2c);}\
    table.pbMainTab tr td.sel { color: #000000; font-size: 12px; font-weight:bold; border-radius: 10px; box-shadow: 0px 1px 3px #357544; text-shadow: -1px 1px 3px #CECECE; border: solid #615461 1px; background: -moz-linear-gradient(to top, #6ff28e, #196b2c);}\
    table.pbMainTab tr td.notSelTools { color: #ffffff; font-size: 12px; font-weight:bold; border-radius: 10px; box-shadow: 0px 1px 3px #357544; text-shadow: -1px 1px 3px #666666; border: solid #615461 1px; background: -moz-linear-gradient(to top, #cfeef7 0%, #73cee7 24%, #0aaad6 44%, #53c2e1 79%, #88d5ea 100%);}\
    table.pbMainTab tr td.selTools { color: #000000; font-size: 12px; font-weight:bold; border-radius: 10px; box-shadow: 0px 1px 3px #357544; text-shadow: -1px 1px 3px #CECECE; border: solid #615461 1px; background: -moz-linear-gradient(to top, #cfeef7 0%, #73cee7 24%, #0aaad6 44%, #53c2e1 79%, #88d5ea 100%);}\
    table.pbMainTab tr td:hover { font-size: 12px; font-weight:bold; text-shadow: -1px 1px 3px #CECECE;}\
    tr.pbPopTop td { background-color:transparent; border:none; height: 21px; padding:0px;}\
    tr.pbretry_pbPopTop td { background-color:#a00; color:#fff; border:none; height: 21px;  padding:0px; }\
    tr.pbMainPopTop td { background-color:#ded; border:none; height: 42px; width:80%; padding:0px; }\
    tr.pbretry_pbMainPopTop td { background-color:#a00; color:#fff; border:none; height: 42px;  padding:0px; }\
    .pbPopMain  { border:1px solid #000000; box-shadow:inset 0px 0px 10px #6a6a6a; border-bottom-right-radius:25px; border-bottom-left-radius:25px;}\
    .pbPopup  {border:5px ridge #666; opacity:'+(parseFloat(Options.Opacity)<'0.5'?'0.5':Options.Opacity)+'; border-radius:25px; box-shadow: 1px 1px 5px #000000; }\
    span.pbTextFriendly {color: #080}\
    span.pbTextHostile {color: #800}\
    span.boldRed {color:#800; font-weight:bold}\
    span.boldDarkRed {color:#600; font-weight:bold}\
    .pbButCancel {background-color:#a00; font-weight:bold; color:#fff}\
    .buttonDash_ON {margin:2px;-moz-box-shadow:inset 0px 0px 14px -3px #f2fadc;-webkit-box-shadow:inset 0px 0px 14px -3px #f2fadc;box-shadow:inset 0px 0px 14px -3px #f2fadc;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dbe6c4), color-stop(1, #9ba892));background:-moz-linear-gradient(top, #dbe6c4 5%, #9ba892 100%);background:-webkit-linear-gradient(top, #dbe6c4 5%, #9ba892 100%);background:-o-linear-gradient(top, #dbe6c4 5%, #9ba892 100%);background:-ms-linear-gradient(top, #dbe6c4 5%, #9ba892 100%);background:linear-gradient(to bottom, #dbe6c4 5%, #9ba892 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#dbe6c4", endColorstr="#9ba892",GradientType=0);background-color:#dbe6c4;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px;border:1px solid #b2b8ad;display:inline-block;color:black;font-family:verdana;font-size:12px;padding:1px 2px;text-decoration:none;}\
    .buttonDash_ON:hover {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #9ba892), color-stop(1, #dbe6c4));background:-moz-linear-gradient(top, #9ba892 5%, #dbe6c4 100%);background:-webkit-linear-gradient(top, #9ba892 5%, #dbe6c4 100%);background:-o-linear-gradient(top, #9ba892 5%, #dbe6c4 100%);background:-ms-linear-gradient(top, #9ba892 5%, #dbe6c4 100%);background:linear-gradient(to bottom, #9ba892 5%, #dbe6c4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#9ba892", endColorstr="#dbe6c4",GradientType=0);background-color:#9ba892;}\
    .buttonDash_OFF {margin:2px;-moz-box-shadow:inset 0px 0px 14px -3px #f7c5c0;-webkit-box-shadow:inset 0px 0px 14px -3px #f7c5c0;box-shadow:inset 0px 0px 14px -3px #f7c5c0;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fc8d83), color-stop(1, #e4685d));background:-moz-linear-gradient(top, #fc8d83 5%, #e4685d 100%);background:-webkit-linear-gradient(top, #fc8d83 5%, #e4685d 100%);background:-o-linear-gradient(top, #fc8d83 5%, #e4685d 100%);background:-ms-linear-gradient(top, #fc8d83 5%, #e4685d 100%);background:linear-gradient(to bottom, #fc8d83 5%, #e4685d 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#fc8d83", endColorstr="#e4685d",GradientType=0);background-color:#fc8d83;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px;border:1px solid #d83526;display:inline-block;color:black;font-family:verdana;font-size:12px;padding:1px 2px;text-decoration:none;}\
    .buttonDash_OFF:hover {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e4685d), color-stop(1, #fc8d83));background:-moz-linear-gradient(top, #e4685d 5%, #fc8d83 100%);background:-webkit-linear-gradient(top, #e4685d 5%, #fc8d83 100%);background:-o-linear-gradient(top, #e4685d 5%, #fc8d83 100%);background:-ms-linear-gradient(top, #e4685d 5%, #fc8d83 100%);background:linear-gradient(to bottom, #e4685d 5%, #fc8d83 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#e4685d", endColorstr="#fc8d83",GradientType=0);background-color:#e4685d;}\
    .pbButton {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e6e6e6), color-stop(1, #878487));background:-moz-linear-gradient(top, #e6e6e6 5%, #878487 100%);background:-webkit-linear-gradient(top, #e6e6e6 5%, #878487 100%);background:-o-linear-gradient(top, #e6e6e6 5%, #878487 100%);background:-ms-linear-gradient(top, #e6e6e6 5%, #878487 100%);background:linear-gradient(to bottom, #e6e6e6 5%, #878487 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#e6e6e6", endColorstr="#878487",GradientType=0);background-color:#e6e6e6;-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;border:1px solid #4f454f;display:inline-block;color:#000000;font-family:verdana;font-size:12px;font-weight:bold;padding:1px 2px;text-decoration:none;text-shadow:0px 1px 0px #e1e2ed;}\
    .pbButton:hover {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #878487), color-stop(1, #e6e6e6));background:-moz-linear-gradient(top, #878487 5%, #e6e6e6 100%);background:-webkit-linear-gradient(top, #878487 5%, #e6e6e6 100%);background:-o-linear-gradient(top, #878487 5%, #e6e6e6 100%);background:-ms-linear-gradient(top, #878487 5%, #e6e6e6 100%);background:linear-gradient(to bottom, #878487 5%, #e6e6e6 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#878487", endColorstr="#e6e6e6",GradientType=0);background-color:#878487;}\
    .pbButton:active {position:relative;top:1px;}\
    .pbButton_selected {-moz-box-shadow:inset 0px 1px 3px 0px #1b1f26;-webkit-box-shadow:inset 0px 1px 3px 0px #1b1f26;box-shadow:inset 0px 1px 3px 0px #1b1f26;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #5c6069), color-stop(1, #000000));background:-moz-linear-gradient(top, #5c6069 5%, #000000 100%);background:-webkit-linear-gradient(top, #5c6069 5%, #000000 100%);background:-o-linear-gradient(top, #5c6069 5%, #000000 100%);background:-ms-linear-gradient(top, #5c6069 5%, #000000 100%);background:linear-gradient(to bottom, #5c6069 5%, #000000 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#5c6069", endColorstr="#000000",GradientType=0);background-color:#5c6069;-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;border:1px solid #000000;display:inline-block;color:#ffffff;font-family:verdana;font-size:12px;font-weight:normal;padding:1px 2px;text-decoration:none;text-shadow:0px -1px 0px #000000;}\
    .hasTooltip {display: inline;position: relative;}\
	.hasTooltip span {display:none;}\
	.hasTooltip:hover span {display:inline-block;z-index:99999;background-color:#FFFFE6;border-radius:5px;color:black;box-shadow:1px 1px 3px gray;position:absolute;padding:5px;top:25px;left:25px;}\
		.Guardian_speed {background: url("https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png") no-repeat scroll -324px -356px transparent;display: block;}\
	.Guardian_hp {background: url("https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/guardian_change_spritemap102.png") no-repeat scroll -346px -356px transparent;display: block;}\
	.Guardian_attack {background: url("https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/guardian_change_spritemap102.png") no-repeat scroll -372px -356px transparent;display: block;}\
	.Guardian_train {background: url("https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/guardian_change_spritemap102.png") no-repeat scroll -284px -356px transparent;width: 32px;display: block;}\
	div.indent25 {padding-left:25px}';
    
  window.name = 'PT';

  readTrainingOptions();
  readCrestOptions();
  readCraftOptions();
  readAtkOptions();
  readDFOptions();
  readmercOptions();
  readFarmOptions();
  readThroneOptions();
  readDashboardOptions();
  readApothecaryOptions();
  readMarchOptions();
  setCities();
  readChatIcons(); 
  bypassMulti.init();
  //GMTclock.init();
  anticd.init();

  setInterval(eachSecond,1000);
  if (firefoxVersion.substring(0,4) >=16){
  	unsafeWindow.jQuery("#hudAvatarPic").attr("class", "");
  	document.getElementById('hudAvatarPic').innerHTML = '<img src="https://graph.facebook.com/'+ unsafeWindow.user_id +'/picture">';
  	document.getElementById('hudAvatarPic').onclick = null;
  }

// TODO: Make sure WinPos is visible on-screen ?
  if (Options.pbWinPos==null || Options.pbWinPos.x==null|| Options.pbWinPos.x=='' || isNaN(Options.pbWinPos.x)){
    var c = getClientCoords (document.getElementById('main_engagement_tabs'));
    Options.pbWinPos.x = c.x+4;
    Options.pbWinPos.y = c.y+c.height;
    saveOptions ();
  }

  // Reset window xPos if the widescreen option is disabled
  if(!GlobalOptions.pbWideScreen && Options.pbWinPos.x > 700){
    var c = getClientCoords (document.getElementById('main_engagement_tabs'));
    Options.pbWinPos.x = c.x+4;
    saveOptions ();
  }

  mainPop = new pbPopup ('pb', Options.pbWinPos.x, Options.pbWinPos.y, 910,800, Options.pbWinDrag,
      function (){
        tabManager.hideTab();
        Options.pbWinIsOpen=false;
        saveOptions();
      });
  mainPop.autoHeight (true);  

  mainPop.getMainDiv().innerHTML = '<STYLE>'+ styles +'</style>';
  AddMainTabLink('AIO', eventHideShow, mouseMainTab);
  AddSubTabLink('Refresh Seed', RefreshSeed, 'pbSeedRefresh');
  var debugUid = ["1112699","9688786","9913393"];
  if (debugUid.indexOf(unsafeWindow.tvuid) >= 0) AddSubTabLink('debug', debugWin.doit, 'pbdebug');
  var outgoingButton = "";
  var incomingButton = "";
  var infoButton = "";
  AddSubTabLink('<img src='+infoButton+'>', QueueMarches.init, 'pbOutgoingButton');
  AddSubTabLink('<img src='+outgoingButton+'>', OutgoingMarches.init, 'pbOutgoingButton');
  AddSubTabLink('<img src='+incomingButton+'>', IncomingMarches.init, 'pbIncomingButton');
  tabManager.init (mainPop.getMainDiv());
  actionLog ("KOC AIO Script v"+ Version +" Loaded  (KofC version: "+ anticd.getKOCversion() +")");
  document.getElementById('pbIncomingButton').style.display = "none";

  WideScreen.init ();
  WideScreen.setChatOnRight (Options.pbChatOnRight);
  WideScreen.useWideMap (Options.pbWideMap);

  FairieKiller.init (Options.pbKillFairie);
  RefreshEvery.init ();
  Dashboard.init();
  SpamEvery.init ();
  CollectGold.init();
  ChatPane.init();
  DeleteReports.init();
  messageNav.init();
  ChatStuff.init ();
  battleReports.init();
  AttackDialog.init();
  CoordBox.init();
  AllianceReports.init();
  DispReport.init();
  AudioManager.init();

  if (Options.pbWinIsOpen && Options.pbTrackOpen){
    mainPop.show (true);
    tabManager.showTab();
  }
  window.addEventListener('unload', onUnload, false);

  killbox();

  var Trasnporter = Options.ReturnToCity;
  if(Options.ReturnToCity) setTimeout(function (){unsafeWindow.citysel_click(document.getElementById('citysel_'+Trasnporter));logit(Trasnporter)},1000);

}

/************************ Food Alerts *************************/
var FoodAlerts = {
  	e_eachMinute : function (){  
    	var f = FoodAlerts;
	    var now = unixTime();
	    row = [];
	    if ((Options.FoodAlertChecked + 3600) < now) {
		    for(i=0; i < Cities.numCities; i++) {
		        var rp = getResourceProduction (Cities.cities[i].id);
		        var foodleft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0])/3600;
		        var usage = rp[1] - parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
		        row[i] = rp[1] - usage;
		        var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-usage) * 3600;
		        var msg = '';
		        if (usage < 0) {
		    		if (Options.pbFoodAlert && timeLeft<(4*3600)&& foofleft < 1000000000) {
            if(!unsafeWindow.cm.PrestigeCityPlayerProtectionController.isActive(Cities.cities[i].id)) {
		            	msg += 'My city '+Cities.cities[i].name.substring(0,10) + ' (' + Cities.cities[i].x +','+ Cities.cities[i].y + ')';
		            	msg += "is low on food. Remaining: "+addCommasWhole(foodleft)+' ('+timestrShort(timeLeft)+') Upkeep: '+addCommas(usage)+' IGNORE IF THERES MORE than 1 bil';
		            	sendChat ("/a " + msg);
                  }
		          	}
		    	}
		    }
		    Options.FoodAlertChecked = now;
		    saveOptions();
		}
  },

}

/*********************************  Farm Tab ***********************************/
//Tabs.farm = {};


/*********************************** Throne Tab ***********************************/

Tabs.Throne = {
  tabOrder : 590,
  tabLabel : 'Throne',
  myDiv : null,
  curTabBut : null,
  curTabName : null,
  SelId:null,
  log:[],
  SalvageLog:[],
  setRepairTimer:null,
  setActionTimer:null,
  SalvageArray:[],
  SalvageRunning:false,
  LastDeleted:0,
  MaxRows:30,
  CompPos:0,
  CardTypes:["ALL","Attack","Defense","Life","Speed","Accuracy","Range","Load","MarchSize","MarchSpeed","CombatSkill","IntelligenceSkill","PoliticsSkill","ResourcefulnessSkill","TrainingSpeed","ConstructionSpeed","ResearchSpeed","CraftingSpeed","Upkeep","ResourceProduction","ResourceCap","Storehouse","Morale","ItemDrop"],
  EquipType: ["ALL","Advisor","Banner","Chair","Candelabrum","Hero","Table","Trophy","Windows"],
  Faction: ["ALL","Briton","Fey","Druid"],
  Quality: ["ALL","Common","Uncommon","Rare","Epic","Wondrous"],
  StatEffects: [],

  init : function (div){
    var t = Tabs.Throne;
    t.myDiv = div;
    unsafeWindow.setFAV = t.setSalvageFAV;
    unsafeWindow.Savlage = t.setSalvageItem;
    unsafeWindow.ActionPopup = t.ActionPopup;

    var a = JSON2.parse(GM_getValue ('ThroneHistory_'+getServerId(), '[]'));
    if (matTypeof(a) == 'array') t.log = a;
    var a = JSON2.parse(GM_getValue ('ThroneSalvageHistory_'+getServerId(), '[]'));
    if (matTypeof(a) == 'array') t.SalvageLog = a;

    var main = '<TABLE class=pbTab width=100%><TR align=center><TD><INPUT class=pbButton ID=ptmrchSubSal type=submit value="Salvage"></td>';
    main +='<TD><INPUT class=pbButton ID=ptmrchSubUE type=submit value="Upgrade"></td>';
	main +='<TD><INPUT class=pbButton ID=ptmrchSubEQ type=submit value="Compare"></td>';
	main +='<TD><INPUT class=pbButton ID=ptmrchSubPR type=submit value="Preset"></td>';
	main +='<TD><INPUT class=pbButton ID=ptmrchSubST type=submit value="Stats"></td>';
	main +='<TD><input class=pbButton ID=ptmrchSubTC type=submit value="Caps"></td></tr></table>';
    main +='<DIV id=ThroneOutput style="margin-top:10px; height:650px; overflow:auto;"></div><BR>';

    t.myDiv.innerHTML = main;
    t.Overv = document.getElementById('ThroneOutput');   
    document.getElementById('ptmrchSubSal').addEventListener('click', e_butSubtab, false);
    document.getElementById('ptmrchSubUE').addEventListener('click', e_butSubtab, false);
	document.getElementById('ptmrchSubEQ').addEventListener('click', e_butSubtab, false);
	document.getElementById('ptmrchSubPR').addEventListener('click', e_butSubtab, false);
	document.getElementById('ptmrchSubST').addEventListener('click', e_butSubtab, false);
	document.getElementById('ptmrchSubTC').addEventListener('click', e_butSubtab, false);
	for (i=1;i<=8;i++) for (j=1;j<t.EquipType.length;j++) if (unsafeWindow.kocThroneItems[ThroneOptions.Presets[i][t.EquipType[j].toLowerCase()]] == undefined) ThroneOptions.Presets[i][t.EquipType[j].toLowerCase()] = 0;   
    changeSubtab (document.getElementById('ptmrchSubUE'));
	changeSubtab (document.getElementById('ptmrchSubEQ'));
    
    function e_butSubtab (evt){changeSubtab (evt.target);}
    function changeSubtab (but){
      	var t = Tabs.Throne;
      	clearInterval(t.timer);
      	if (but == t.curTabBut) return;
      	if (t.curTabBut){
        	t.curTabBut.className='pbButton'; 
        	t.curTabBut.disabled=false;
      	}
      	t.curTabBut = but;
      	but.className='pbButton_selected'; 
      	but.disabled=true;
      	t.curTabName = but.id.substr(9);
      	t.show ();
    }
    t.checkUpgradeInfo(true);
 },

 saveSalvageOptions : function(){
		for (k in unsafeWindow.cm.thronestats.effects) {
			var ele = document.getElementById('pbThroneItems'+k);
			ThroneOptions.Salvage[k]=ele.checked;
		}		
		saveThroneOptions();
   },
    
 Salvage : function (){ 
    var t = Tabs.Throne; 
    try {      
      m = '<DIV id=pbTowrtDivF class=pbStat>AUTOMATED SALVAGE FUNCTION</div><TABLE id=pbbarbingfunctions width=100% class=pbTab>';
	  m+='<TR><TD><INPUT class="buttonDash_'+ (Options.ThroneDeleteItems?'ON':'OFF') +'" type=submit id=pbsalvage_run value="Auto Salvage = '+(Options.ThroneDeleteItems?'ON':'OFF')+'" /></td><TD><INPUT id=ShowSalvageHistory type=submit  class=pbButton value="History"></td><TD>Keep items with more than <INPUT type=text id=pbthrone_keep size=3 value="'+ThroneOptions.thronekeep+'" /> stats checked.</td></tr>';
	  m+='<TD>Keep first <INPUT type=text id=saveXitems size=2 maxlength=2 value='+ ThroneOptions.saveXitems +'> items.</td><TD><FONT color=red>Check boxes for items you want to <b>KEEP</b>.</font></td></table>';   
      m+='<TABLE id=pbbarbingfunctions width=80% class=pbTab>';
      for (k in unsafeWindow.cm.thronestats.effects) {
      	m += '<TR><TD><A onclick="setFAV('+ k +')"><DIV class=pbSalvage_fav id=SalvageFAV'+k+'></div></td>';
      	m += '<TD class=pbThrone1>Slot: <SELECT class=pbSalvage_slot id="slot'+k+'" type=list></select></td><TD class=pbThrone2>Type: <SELECT class=pbSalvage_Type id="Type'+k+'" type=list></select></td><TD class=pbThrone><INPUT id=pbThroneItems'+k+' type=checkbox checked=true>'+ unsafeWindow.cm.thronestats.effects[k][1] +'</td><TD>'+ unsafeWindow.cm.thronestats.effects[k][3]+'</td><TD>'+ unsafeWindow.cm.thronestats.effects[k][2]+'</td></tr>';
      }	
      m+= '</table>';

    t.Overv.innerHTML = m;

    for (k in unsafeWindow.cm.thronestats.effects){
    	var id = "slot" + k; 
	    document.getElementById(id).options.length=0;
		for (i=1;i<=5;i++){
				var o = document.createElement("option");			
				if (i<5) o.text = i+"+";
				else o.text = i;
				o.value = i;
				document.getElementById(id).options.add(o);
		}	
	}
	for (k in unsafeWindow.cm.thronestats.effects){
    	var id = "Type" + k; 
	    document.getElementById(id).options.length=0;
		for (i in t.EquipType){
				var y = t.EquipType[i];
				if (typeof(y) == "string") {
					if (y == "Windows") y = "Window";
					what = y.toLowerCase();
					if (y == "Chair") y = "Throne";
					var o = document.createElement("option");	
					o.text = y;
					o.value = what;
					document.getElementById(id).options.add(o);
			}
		}	
	}
    $("pbsalvage_run").addEventListener('click', t.ToggleSalvageState,false);
      if (ThroneOptions.Salvage[1] != undefined){
		  for (k in unsafeWindow.cm.thronestats.effects){
				document.getElementById('pbThroneItems'+k).checked = ThroneOptions.Salvage[k]; 
			}
	  }
	  if (ThroneOptions.Salvage_fav[1] == undefined){
	  		for (k in unsafeWindow.cm.thronestats.effects){
				ThroneOptions.Salvage_fav[k] = false;
			}
	  } 
	if (ThroneOptions.Salvage_fav[1] != undefined) {
	  		for (k in unsafeWindow.cm.thronestats.effects){
				if (ThroneOptions.Salvage_fav[k]) document.getElementById('SalvageFAV'+k).innerHTML = '<img src=""/>';
					else document.getElementById('SalvageFAV'+k).innerHTML = '<img src="" />';
			}
	}

	if (ThroneOptions.Salvage_slots[1] == undefined){
	  		for (k in unsafeWindow.cm.thronestats.effects){
				ThroneOptions.Salvage_slots[k] = 1;
			}
	} else {
	  		for (k in unsafeWindow.cm.thronestats.effects){
				 document.getElementById('slot'+k).value = ThroneOptions.Salvage_slots[k];
				 if (!document.getElementById('pbThroneItems'+k).checked) document.getElementById('slot'+k).disabled = true;
			}
	}

	if (ThroneOptions.Salvage_Type[1] == undefined){
	  		for (k in unsafeWindow.cm.thronestats.effects){
				ThroneOptions.Salvage_Type[k] = "ALL";
			}
	} else {
	  		for (k in unsafeWindow.cm.thronestats.effects){
				 document.getElementById('Type'+k).value = ThroneOptions.Salvage_Type[k];
				 if (!document.getElementById('pbThroneItems'+k).checked) document.getElementById('Type'+k).disabled = true;
			}
	}


    var element_class = document.getElementsByClassName('pbThrone');
    for (k=0;k<element_class.length;k++){
    	element_class[k].addEventListener('click', function(){
    		for (k in unsafeWindow.cm.thronestats.effects){
				if (!document.getElementById('pbThroneItems'+k).checked) document.getElementById('slot'+k).disabled = true;	
				else  document.getElementById('slot'+k).disabled = false;
				if (!document.getElementById('pbThroneItems'+k).checked) document.getElementById('Type'+k).disabled = true;	
				else  document.getElementById('Type'+k).disabled = false;
			}
    		t.saveSalvageOptions();
    	} , false);
    }

    var element_class = document.getElementsByClassName('pbThrone1');
    for (k=0;k<element_class.length;k++){
    	element_class[k].addEventListener('change', function(){
    		for (k in unsafeWindow.cm.thronestats.effects){
				ThroneOptions.Salvage_slots[k] = parseInt(document.getElementById('slot'+k).value);
			}
    		t.saveSalvageOptions();
    	} , false);
    }

    var element_class = document.getElementsByClassName('pbThrone2');
    for (k=0;k<element_class.length;k++){
    	element_class[k].addEventListener('change', function(){
    		for (k in unsafeWindow.cm.thronestats.effects){
				ThroneOptions.Salvage_Type[k] = document.getElementById('Type'+k).value;
			}
    		t.saveSalvageOptions();
    	} , false);
    }

    t.saveSalvageOptions();
      
    document.getElementById('pbthrone_keep').addEventListener ('change', function(){ThroneOptions.thronekeep = parseInt(document.getElementById('pbthrone_keep').value);saveThroneOptions();},false);
    document.getElementById('saveXitems').addEventListener('change', function(){ThroneOptions.saveXitems = document.getElementById('saveXitems').value;saveThroneOptions();} , false);
    document.getElementById('ShowSalvageHistory').addEventListener('click', function(){t.PaintSalvageHistory()} , false);
      
    } catch (e) {
      t.Overv.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  },
 
setSalvageFAV :function (what){
	 var t = Tabs.Throne;  
	 if (ThroneOptions.Salvage_fav[what]) ThroneOptions.Salvage_fav[what] = false;
	 	else  ThroneOptions.Salvage_fav[what] = true;
	 for (k in unsafeWindow.cm.thronestats.effects){
				if (ThroneOptions.Salvage_fav[k]) document.getElementById('SalvageFAV'+k).innerHTML = '<img src=""/>';
					else document.getElementById('SalvageFAV'+k).innerHTML = '<img src="" />';
	}
	t.saveSalvageOptions();
},

ToggleSalvageState :function (what){
	 var t = Tabs.Throne; 
	 	if(Options.ThroneDeleteItems){
			if (document.getElementById('pbsalvage_run')) {document.getElementById('pbsalvage_run').value = "Salvage = OFF";document.getElementById('pbsalvage_run').setAttribute("class", "buttonDash_OFF");}
        	if (document.getElementById('AutoSalvageToggle')) {document.getElementById('AutoSalvageToggle').value = "Salvage = OFF";document.getElementById('AutoSalvageToggle').setAttribute("class", "buttonDash_OFF");}
			Options.ThroneDeleteItems = false;
			saveOptions();
		} else {
			if (document.getElementById('pbsalvage_run')) {document.getElementById('pbsalvage_run').value = "Salvage = ON";document.getElementById('pbsalvage_run').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('AutoSalvageToggle')){document.getElementById('AutoSalvageToggle').value = "Salvage = ON";document.getElementById('AutoSalvageToggle').setAttribute("class", "buttonDash_ON");}
			Options.ThroneDeleteItems = true;
			saveOptions();
		} 	 
},


setSalvageItem :function (what){
	var t = Tabs.Throne;  
	var answer = confirm ("Are you sure you want to delete: " + unsafeWindow.kocThroneItems[what].name);
	if (answer) {
		var cityid = 0;
		for (var k in Cities.byID) {
				if (Seed.resources["city"+k]["rec5"][0] < 1000000)
				{
				   cityid = k;
				   break;
				}
		}
		if (cityid == 0) cityid = Seed.cities[0][0];
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'salvage';
		params.itemId = what;
		params.cityId = cityid;
		
	      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				loading: true,
				onSuccess: function (transport) {
					var rslt = eval("(" + transport.responseText + ")");
					if(rslt.ok) {
						unsafeWindow.kocThroneItems[params.itemId].salvage();
						t.FillEquipCheckboxes();
					}
				},
				onFailure: function () {
						return;
				},
			});
	}
},


Upgrade_Enhance :function (){
    var t = Tabs.Throne;  
    try {      
      var m = '<DIV id=pbTowrtDivF class=pbStat>AUTOMATED UPGRADE/ENHANCE/REPAIR FUNCTION</div><TABLE id=pbbarbingfunctions width=100% height=0% class=pbTab><TR align="center">';
	  m +='<TD><INPUT class="buttonDash_'+ (ThroneOptions.Active?'ON':'OFF') +'" id=Enable type=submit value="'+translate("Queue")+' = '+ (ThroneOptions.Active?'ON':'OFF')+'"></td>'
      m+= '<TD><INPUT id=ShowHistory type=submit class=pbButton value="History"></td>';
      m+= '</table><DIV id=pbTowrtDivF class=pbStat>OPTIONS</div>';
	  m+= '<BR><INPUT id=pbUseTokens type=checkbox '+ (ThroneOptions.UseTokens?'CHECKED ':'') +'/>&nbsp;Use Tokens/Stones when available, from and above -> Quality: ';
	  m+= '<SELECT id="pbLPSlevel">';
	  for (var i=0;i<t.Quality.length-1;i++)  m+='<OPTION value='+i+' >'+t.Quality[i]+'</option>';
	  m+= '</select> - Level: <SELECT id="pbLLTlevel">';	
	  for (var i=1;i<=13;i++)  m+='<OPTION value='+i+' >'+i+'</option>';
	  m+= '</select><BR>To add cards to queue: Go to compare, click the card title and select action...';
	  m+= '<BR><BR><TABLE class=pbTab align=center><TD><INPUT id=allEnhance type=submit class=pbButton value="Enhance All Cards One Level"></td><TD><INPUT id=allUpgrade type=submit class=pbButton value="Upgrade All Cards One Level"></td></table>';
	  m+= '<DIV id=pbTowrtDivF class=pbStat>STATUS</div>';
	  m+= '<br/><DIV id=ShowStatus></div></p>';
	  m+= '<DIV id=ShowTries></div><br/>';
	  m+= '<DIV id=ShowStones></div><br/>';
      m+= '<DIV id=pbTowrtDivF class=pbStat>QUEUE</div>';
	  m+= '<br/><DIV id=ShowQueueDiv></div>';
	  t.Overv.innerHTML = m;
      
	document.getElementById('allEnhance').addEventListener ('click', function (){
		var counter=0;
		for (k in unsafeWindow.kocThroneItems) {
			counter++;
			ActiveItems = parseInt(Seed.throne.rowNum)*5;
			if (counter > ActiveItems) break;
			y = unsafeWindow.kocThroneItems[k];
			if (y.quality <=4) t.addToQueue(y.id,"Enhance");	
		}		
	},false);
	document.getElementById('allUpgrade').addEventListener ('click', function (){
		var counter=0;
		for (k in unsafeWindow.kocThroneItems) {
			counter++;
			ActiveItems = parseInt(Seed.throne.rowNum)*5;
			if (counter > ActiveItems) break;
			y = unsafeWindow.kocThroneItems[k];
			if (y.level <=9) t.addToQueue(y.id,"Upgrade");	
		}		
	},false);

	document.getElementById('pbLLTlevel').value = ThroneOptions.LLTlevel;
	document.getElementById('pbLPSlevel').value = ThroneOptions.LPSlevel;
  	document.getElementById('pbUseTokens').addEventListener('change', function(){ThroneOptions.UseTokens = document.getElementById('pbUseTokens').checked;saveThroneOptions();} , false);
  	document.getElementById('pbLLTlevel').addEventListener('change', function(){ThroneOptions.LLTlevel = document.getElementById('pbLLTlevel').value;saveThroneOptions();} , false);
  	document.getElementById('pbLPSlevel').addEventListener('change', function(){ThroneOptions.LPSlevel = document.getElementById('pbLPSlevel').value;saveThroneOptions();} , false);
  	document.getElementById('Enable').addEventListener('click', function(){t.toggleThroneState()} , false);
  	document.getElementById('ShowHistory').addEventListener('click', function(){t.PaintHistory()} , false);
  
	if (ThroneOptions.Items.length ==0) t.UpdateShowStatus("No items in queue!!");
	else {
      if (ThroneOptions.Active && Seed.queue_throne.end == undefined) t.UpdateShowStatus("Waiting for timer...");
      if (ThroneOptions.Active && Seed.queue_throne.end != undefined) t.setRepairTimer = setInterval (t.repairTimerUpdate,1000);
      if (!ThroneOptions.Active && Seed.queue_throne.end != undefined) t.setRepairTimer = setInterval (t.repairTimerUpdate,1000); 
      if (!ThroneOptions.Active && Seed.queue_throne.end == undefined) t.UpdateShowStatus("Auto Upgrade/Enhance/Repair is OFF.");
    } 
        
	if (ThroneOptions.Tries > 0) t.UpdateShowTries("Tries: " + ThroneOptions.Tries + "<br />Good requests: " + ThroneOptions.Good + "   Bad requests: " + ThroneOptions.Bad);
		else t.UpdateShowTries("Tries: --");
   	
	if (ThroneOptions.Items.length>0) {t.paintStones();t.PaintQueue();}
    
  } catch (e) {
      t.Overv.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  t.timer = setInterval(t.paintStones,2500);
},

UpdateShowStatus : function (msg){
	if (document.getElementById('ShowStatus') != null) document.getElementById('ShowStatus').innerHTML = msg;
	if (document.getElementById('UpgradeStatus') != null) document.getElementById('UpgradeStatus').innerHTML = msg;

},

UpdateShowTries: function (msg){
	if (document.getElementById('ShowTries') != null) document.getElementById('ShowTries').innerHTML = msg;
	if (document.getElementById('TriesStatus') != null) document.getElementById('TriesStatus').innerHTML = msg;

},

Compare :function (){
    var t = Tabs.Throne;  
    var amount = 0;
    var AdvisorCount =0;
    var BannerCount = 0;
	var CandelabrumCount = 0;
	var HeroCount = 0;
    var ChairCount = 0;
    var TableCount = 0;
    var TrophyCount = 0;
    var WindowCount = 0;
    var counter = 0;
    ActiveItems = parseInt(Seed.throne.rowNum)*5;

    for (k in unsafeWindow.kocThroneItems){
		counter++;
		if (counter > ActiveItems) break;
		z = unsafeWindow.kocThroneItems[k];
		if (z.type=="advisor") AdvisorCount++;
		if (z.type=="banner") BannerCount++;
		if (z.type=="candelabrum") CandelabrumCount++;
		if (z.type=="hero") HeroCount++;
		if (z.type=="chair") ChairCount++;
		if (z.type=="trophy") TrophyCount++;
		if (z.type=="table") TableCount++;
		if (z.type=="window") WindowCount++;
	}	

    try {   
     var m = '<DIV id=pbTowrtDivF class=pbStat>Compare Throne Items</div><br><TABLE id=pbCompareStats width=100% height=0% class=pbTab>';

     m+='<TD>Advisor: ' + AdvisorCount + '</td><TD>Banner: ' + BannerCount+ '</td><TD>Candelabrum: ' + CandelabrumCount+ '</td><TD>Hero: ' + HeroCount+ '</td><TD>Throne :' + ChairCount+ '</td><TD>Table: '+ TableCount+'</td><TD>Trophy: ' + TrophyCount + '</td><TD>Window: ' + WindowCount + '</td></table><br>';

     m+= '<DIV id=pbThroneMain class=pbStat>Compare Throne Items</div><br>';
     m+='<TABLE id=pbCompareStats width=100% height=0% class=pbTab><TD>Card Type: <SELECT id=type type=list></select></td><TD>Card quality: <SELECT id=CardQuality type=list></select></td><TD>Effect: <SELECT id=effect type=list></select></td></tr><TR><TD>Keyword: <INPUT type=text id=keyword size=10></td><TD><INPUT id=isEquipped type=checkbox unchecked=true> Equipped</td></tr></table>';

     m+='<br><TABLE id=pbbarbingfunctions width=100% height=0% class=pbTab><TR>';

     for (i=1;i<=ActiveItems;i++){
     	 m+='<TD><DIV id=DIV'+ i +'></div></td>';
     	 if (i%3==0) m+='</tr><TR></tr><TR>';
     }

     m+="</tr></table>"

    t.Overv.innerHTML = m;

	document.getElementById("type").options.length=0;
	for (k in t.EquipType){
		var y = t.EquipType[k];
		if (typeof(y) == "string") {
			if (y == "Windows") y = "Window";
			what = y.toLowerCase();
			if (y == "Chair") y = "Throne";
			var o = document.createElement("option");			
			o.text = y;
			o.value = what;
			document.getElementById("type").options.add(o);
		}		
	}	
	document.getElementById("CardQuality").options.length=0;
	for (i=0;i<=t.Quality.length;i++){
		var y = t.Quality[i];
		if (typeof(y) == "string") {
			var o = document.createElement("option");			
			o.text = y;
			o.value = i;
			document.getElementById("CardQuality").options.add(o);
		}		
	}	
	document.getElementById("effect").options.length=0;
	var o = document.createElement("option");			
	o.text = "ALL";
	o.value = "ALL";
	document.getElementById("effect").options.add(o);
	for (k in unsafeWindow.cm.thronestats.effects){
		var y = unsafeWindow.cm.thronestats.effects[k][1];
		if (typeof(y) == "string") {
			var o = document.createElement("option");			
			o.text = unsafeWindow.cm.thronestats.effects[k][1];
			o.value = k;
			document.getElementById("effect").options.add(o);
		}		
	}	

	document.getElementById("type").addEventListener ('change', t.FillEquipCheckboxes,false);
	document.getElementById("CardQuality").addEventListener ('change', t.FillEquipCheckboxes,false);
	document.getElementById("effect").addEventListener ('change', t.FillEquipCheckboxes,false);
	document.getElementById("keyword").addEventListener ('change', t.FillEquipCheckboxes,false);
	document.getElementById('keyword').addEventListener('keyup', t.FillEquipCheckboxes, false)
    document.getElementById("isEquipped").addEventListener ('change', t.FillEquipCheckboxes,false);  

	t.FillEquipCheckboxes();
    } catch (e) {
      t.Overv.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
},

Preset :function (){
    var t = Tabs.Throne; 
    var what="";
    try {   
     	var m = '<DIV id=pbTowrtDivF class=pbStat>PRESETS</div><DIV id=PresetCont></div>';     	
    	t.Overv.innerHTML = m;
    	t.PaintPresets();	
    } catch (e) {
     	t.Overv.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
},

Stats : function (){
    var t = Tabs.Throne; 
    var what="";
    try {   
     	var m = '<DIV id=pbTowrtDivF class=pbStat>STATS</div><TABLE id=pbCompareStats width=100% height=0% class=pbTab><BR>';     	
    	
    	for (k in unsafeWindow.cm.thronestats.effects) t.StatEffects[k] = 0;
    	for (k in unsafeWindow.kocThroneItems){
    		 y = unsafeWindow.kocThroneItems[k];
	    	 for (i=1;i<=5;i++) {
				   id = y["effects"]["slot"+i]["id"];
				   tier = parseInt(y["effects"]["slot"+i]["tier"]);
				   level = y["level"];
				   p = unsafeWindow.cm.thronestats.tiers[id][tier];
				   Current = p.base + ((level * level + level) * p.growth * 0.5);
				   if (y.isEquipped && i<=y["quality"]) t.StatEffects[id] += Current
			}
		}
		for (k=1;k<t.StatEffects.length;k++) if (t.StatEffects[k] != 0) m+='<TR><TD width="100px"></td><TD width="75px"><FONT color=black size=3><B>' + t.StatEffects[k] + "%</b></font></td><TD><FONT color=black size=3><B>" + unsafeWindow.cm.thronestats["effects"][k]["1"] + '</b></font></td></tr>';
		m +='</table>';
    	t.Overv.innerHTML = m;    	

    } catch (e) {
     	t.Overv.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
},

Caps : function (){
	var t = Tabs.Throne;
  
	m =  '<DIV class=pbStat><b>Throne Room Caps</b></div><BR><BR><TABLE border=2px align=center>';
    m += '<TR><TD width="150px"><B>Throne Card Effect</b></td><TD width="50px"><B>Buff</b></td><TD><B>Debuff</b></td><TD style="border:0;width:50px"></td><TD width="150px"><B>Throne Rooms Effect</b></td><TD width="50px"><B>Buff</b></td><TD width="50px"><B>Debuff</b></td></tr><TR>';
    var counter =0;
    var ccnt
    for (k in unsafeWindow.cm.thronestats.boosts){
    	counter++;
      ccnt++;
    	var boost = unsafeWindow.cm.thronestats.boosts[k]
      //ThroneOptions.testd.push(boost.Max);
    	m += '<TD>'+ boost.BoostName + '</td><TD>'+ boost.Max +'<SPAN id=maxPerc_'+k+'></div></td><TD>' + boost.Min + '<SPAN id=minPerc_'+k+'></div>';

    	if (counter % 2 == 0){
    		m += '<TR>';
    	}else {
    		m += '</td><TD style="border:0">';
    	}
    }
		t.Overv.innerHTML = m;
    for (k in unsafeWindow.cm.thronestats.boosts){
    	var boost = unsafeWindow.cm.thronestats.boosts[k]
    	if (boost.CapType == "percent"){
	   		document.getElementById('maxPerc_'+k).innerHTML = '%'
    		if (boost.Min != "none"){
    			document.getElementById('minPerc_'+k).innerHTML = '%'
    		}
    	}
    }
},


PaintPresets : function (){
    var t = Tabs.Throne;
    var m= '<TABLE id=pbCompareStats width=100% height=100% class=pbTab>';
     	
     	for (i=1;i<=8;i++) {
     		m+='<TR><TD>&nbsp</td></tr><TR><TD rowspan=7><a class="button20" id=Button'+i+'><span>'+i+'</span></a><INPUT type=text id=PresetName'+i+' size=20 value="'+ ThroneOptions.PresetName[i] +'"</td>';
     		for (j=1;j<t.EquipType.length;j++) {
     			what1 = t.EquipType[j];     			
     			id1 = ThroneOptions.Presets[i][what1.toLowerCase()];
     			if (what1 == "Chair") what1 = "Throne";
     			if (what1 == "Windows") what1 = "Window";
     			if (unsafeWindow.kocThroneItems[id1] != undefined) name1 = unsafeWindow.kocThroneItems[id1].name
     				else name1 = "";     			
     			if (j%2>0) m+='<TR>';
     			if (unsafeWindow.kocThroneItems[id1] != undefined && unsafeWindow.kocThroneItems[id1].isEquipped) m+='<TD>' + what1 + ': <B>' + name1 + '</b></td>';
     				else  m+='<TD>' + what1 + ': ' + name1 + '</td>';
     			if (j%2==0) m+='</tr>';
     		}
     		m+='</tr><TR><TD>&nbsp</td></tr>';
     	}
     	document.getElementById('PresetCont').innerHTML = m;

     	for (i=1;i<=8;i++) {
    		document.getElementById('PresetName'+i).addEventListener('change',function (){
    			for (j=1;j<=8;j++) ThroneOptions.PresetName[j] = document.getElementById('PresetName'+j).value;
    			saveThroneOptions();
    		},false);
    		document.getElementById('Button'+i).addEventListener('click',function (){
    			var what = this.id.substr(6);
    			t.EquipPreset(what);
    		},false);
    	}
},

EquipPreset : function (what){
    var t = Tabs.Throne;   
    var counter= 0;
    for (d=1;d<=7;d++) {
    	var type = t.EquipType[d].toLowerCase();
    	id = ThroneOptions.Presets[what][type];    	
    	if (unsafeWindow.kocThroneItems[id] != undefined && !unsafeWindow.kocThroneItems[id].isEquipped) {
    		counter++;
    		setTimeout(t.doEquip,(5250*(counter-1)),id,"Preset");
    	}
    }
	var msg="";
	if (document.getElementById("PresetCont") != undefined) document.getElementById("PresetCont").innerHTML= msg;
	if (document.getElementById("ShowTrPresets") != undefined) document.getElementById("ShowTrPresets").innerHTML= msg;
	time = Math.round(counter * 5.25);
	Tabs.AutoTrain.changeTime = time;
	for (c=0;c<=time;c++){
		msg = '<DIV align="center"><FONT size="10"><B>Time left is : ' + (time - c) + '</b></font></div>';
		setTimeout(t.TimeLeft,c*1000,msg);

	}  	    
	if (document.getElementById("PresetCont") != undefined) setTimeout(t.PaintPresets,time*1000);
	if (document.getElementById("ShowTrPresets") != undefined) {
		if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") setTimeout(Dashboard.ShowTrPresets,time*1000);
		else setTimeout(Dashboard.ShowTrPresets,time*1000);
	}
},

EquipKabamPreset : function (what){
    var t = Tabs.Throne;   
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
    params.action = 'setPreset';
    params.presetId = what;
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        loading: true,
        onSuccess: function (transport) {
            var rslt = eval("(" + transport.responseText + ")");
            if(rslt.ok){
				for (i=1;i<=Seed.throne.slotNum;i++) {
					if (params.presetId==i && document.getElementById(''+i)) document.getElementById('KabamPreset_'+i).setAttribute("class", "pbButton_selected");
					 else if (document.getElementById('KabamPreset_'+i)) document.getElementById('KabamPreset_'+i).setAttribute("class", "button");
					if (document.getElementById('KabamPreset_Chat_'+i) && params.presetId==i) document.getElementById('KabamPreset_Chat_'+i).setAttribute("class", "pbButton_selected");
					 else if (document.getElementById('KabamPreset_Chat_'+i)) document.getElementById('KabamPreset_Chat_'+i).setAttribute("class", "pbButton");

				} 
				if(document.getElementById('throneInventoryPreset'+params.presetId))
                  button = document.getElementById('throneInventoryPreset'+params.presetId);
               	else
                  button = '<li id="throneInventoryPreset' + params.presetId + '" class="selected">'+params.presetId+'</li>';
				unsafeWindow.cm.ThroneView.clickActivePreset(button);	
				if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") Dashboard.ShowTrPresets();
			 	 else Dashboard.ShowTrPresets();
            }
            else alert("Failed to change throne room...\nTry Again!");
        },
        onFailure: function () {alert("Failed to change throne room...\nTry Again!");},
    });
},

togOpt : function (checkboxId, optionName, callOnChange){
    var t = Tabs.Throne;
    var checkbox = document.getElementById(checkboxId);
    if (Options[optionName])
      checkbox.checked = true;
    checkbox.addEventListener ('change', eventHandler, false);
    function eventHandler (){
      Options[optionName] = this.checked;
      saveOptions();
      if (callOnChange)
        callOnChange (this.checked);
    }
},

changeOpt : function (valueId, optionName, callOnChange){
    var t = Tabs.Throne;
    var e = document.getElementById(valueId);
    e.value = Options[optionName];
    e.addEventListener ('change', eventHandler, false);
    function eventHandler (){
      Options[optionName] = this.value;
      saveOptions();
      if (callOnChange)
        callOnChange (this.value);
    }
},
  
toggleThroneState: function(){
	var t = Tabs.Throne;
	if (ThroneOptions.Active == true) {
		    ThroneOptions.Active = false;
		    document.getElementById('Enable').value = "Queue = OFF";
		    saveThroneOptions();
            clearTimeout(t.setActionTimer);
            if (Seed.queue_throne.end == undefined) t.UpdateShowStatus("Auto Upgrade/Enhance/Repair is OFF.");
	} else {
		    ThroneOptions.Active = true;
		    document.getElementById('Enable').value = "Queue = ON";
		    saveThroneOptions();
            t.UpdateShowStatus("Waiting for timer...");
	}
},

_addTab: function(id,name,qualityfrom,qualityto,levelfrom,levelto,action,active,cost){
	 	var t = Tabs.Throne;
	    var a="";
	    var b=""; 
	    switch (qualityfrom) {
        		case 0:a = unsafeWindow.g_js_strings.throneRoom.simple;break;
        		case 1:a = unsafeWindow.g_js_strings.throneRoom.common;break;
        		case 2:a = unsafeWindow.g_js_strings.throneRoom.uncommon;break;
       			case 3:a = unsafeWindow.g_js_strings.throneRoom.rare;break;
        		case 4:a = unsafeWindow.g_js_strings.throneRoom.epic;break;
        		case 5:a = unsafeWindow.g_js_strings.throneRoom.wondrous;break;
        		default:a = unsafeWindow.g_js_strings.throneRoom.simple;break;
        }
        switch (qualityto) {
        		case 0:b = unsafeWindow.g_js_strings.throneRoom.simple;break;
        		case 1:b = unsafeWindow.g_js_strings.throneRoom.common;break;
        		case 2:b = unsafeWindow.g_js_strings.throneRoom.uncommon;break;
       			case 3:b = unsafeWindow.g_js_strings.throneRoom.rare;break;
       			case 4:b = unsafeWindow.g_js_strings.throneRoom.epic;break;
        		case 5:b = unsafeWindow.g_js_strings.throneRoom.wondrous;break;
        		default:b = unsafeWindow.g_js_strings.throneRoom.simple;break;
        }
	     if (document.getElementById('ShowQueue') != null) {
	     	 var row = document.getElementById('ShowQueue').insertRow(0);
		     row.vAlign = 'top';
		     row.style.color = "black";	
		     if (active) row.style.color = "green";	 
		     row.insertCell(0).innerHTML = id+1;
			 row.insertCell(1).innerHTML = name;
		     if (action == "Enhance") {
					row.insertCell(2).innerHTML = a + " -> " + b;
		   	 		row.insertCell(3).innerHTML = levelfrom;
		     }
		     if (action == "Upgrade") {
					row.insertCell(2).innerHTML = a;
		   	 		row.insertCell(3).innerHTML = levelfrom + " -> " + levelto;
		     }
		     row.insertCell(4).innerHTML = action;
			 row.insertCell(5).innerHTML = cost;
		     row.insertCell(6).innerHTML = '<a class="button20" id="queueDelete_' + id + '"><span>Delete</span></a>';
		 }
         if (document.getElementById('queueDelete_' + id) != null) {
         	document.getElementById('queueDelete_' + id).addEventListener('click', function(){
	            if (ThroneOptions.Items[id].active ==true) ThroneOptions.Tries=0;
				if (ThroneOptions.Items.length ==0 && ThroneOptions.Active) t.UpdateShowStatus("No items in queue!!");
				if (!ThroneOptions.Active) t.UpdateShowStatus("Auto Upgrade/Enhance/Repair is OFF.");
				ThroneOptions.Items.splice (id,1);
				saveThroneOptions();
				t.checkUpgradeInfo(false);
	      		t.PaintQueue();
        	}, false);
        }
},
	
_addTabHeader: function() {
	if (document.getElementById('ShowQueue') != null) {
		 var t = Tabs.Throne;
	     var row = document.getElementById('ShowQueue').insertRow(0);
	     row.vAlign = 'top';
	     row.style.color = "black";
	     row.insertCell(0).innerHTML = "Id";
	     row.insertCell(1).innerHTML = "Name";
	     row.insertCell(2).innerHTML = "Quality";
	     row.insertCell(3).innerHTML = "Level";
	     row.insertCell(4).innerHTML = "Action";
		 row.insertCell(5).innerHTML = "Cost";
	     row.insertCell(6).innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	}
},


FillEquipCheckboxes: function(){
	var t = Tabs.Throne;
	var qualityCheck=false;
	var typeCheck=false;
	var effectCheck=false;
	var keywordCheck=false; 
	var equippedCheck = false; 
	ActiveItems = parseInt(Seed.throne.rowNum)*5;
	for(i=1;i<=ActiveItems;i++) document.getElementById("DIV"+i).innerHTML="";
	counter = 0;
	t.CompPos=0;
	for (k in unsafeWindow.kocThroneItems){
		counter++;
		if (counter > ActiveItems) break;
		z = unsafeWindow.kocThroneItems[k];
		qualityCheck=false;
		typeCheck=false;
		effectCheck=false;
		keywordCheck=false;
		equippedCheck = false; 
		y = z.effects;
		if (z.type==document.getElementById("type").value || "all" == document.getElementById("type").value) typeCheck=true;
		if (z.quality >= document.getElementById("CardQuality").value || 0 == document.getElementById("CardQuality").value) qualityCheck = true;
		if (document.getElementById("isEquipped").checked && z.isEquipped) equippedCheck = true;
		if (!document.getElementById("isEquipped").checked) equippedCheck = true;

		for (i=1;i<=5;i++){
				if (y['slot'+i].id == document.getElementById("effect").value || "ALL" == document.getElementById("effect").value) effectCheck = true;
				var str = String(unsafeWindow.cm.thronestats['effects'][y['slot'+i].id][1]);
				if (str.search(new RegExp(String(document.getElementById("keyword").value), "i")) != -1 || document.getElementById("keyword").value=="") keywordCheck=true;
		}

		if (typeCheck && qualityCheck && effectCheck && keywordCheck && equippedCheck){
			t.CompPos++;
			t.paintEquipInfo(z.id,t.CompPos);
		}
	}	
},

doPreset : function (preset){
	var t = Tabs.Throne;
	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
	params.action = 'setPreset';
	params.presetId = preset;
	
				
  	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
		method: "post",
		parameters: params,
		loading: true,
		onSuccess: function (transport) {
			var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					button = '<li id="throneInventoryPreset' + preset + '" class="active">'+preset+'</li>';
					unsafeWindow.cm.ThroneView.clickActivePreset(button);
					t.FillEquipCheckboxes();
			   } 
		},
		onFailure: function () {
		   return;
		},
	});
		
},

paintEquipInfo : function (z,what){
		var t = Tabs.Throne;
		var m="";
		var color = "black";
		if (typeof(unsafeWindow.kocThroneItems[z]) == 'object') var y = unsafeWindow.kocThroneItems[z];
		else return;
		  var id =0;
		  var tier=0;
		  var Current=0;
		  var icon = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/' + y.faction + '/' + y.faction + '_'+ y.type +'_normal_1_'+ y.quality+'.png';
		  if (y.isEquipped) m='<TABLE width=80% height=0% align="center" class=ThroneEQ style="background: transparent url('+icon +') bottom right no-repeat; background-color:#FFFFE3;">';
		  else m='<TABLE width=80% height=0% align="center" class=Throne style="background: transparent url('+icon +') bottom right no-repeat; background-color:#FFFFE3;">';
		  switch(parseInt(y["quality"])){
			case 1:color="grey";break;
			case 2:color="white";break;
			case 3:color="green";break;
			case 4:color="blue";break;
			case 5:color="purple";break;
			default:break;
		  }

   		 m+='<TR><TD style="background-color:#D5C795"><A onclick="ActionPopup('+ y.id +')"><FONT color='+ color +'><B>' + y.name + '</b></font></td>';
		  m+= '<TD><A onclick="Savlage('+ y.id +')"><img src=""/></td></tr>';
		  for (i=1;i<=5;i++) {
			   id = y["effects"]["slot"+i]["id"];
			   tier = parseInt(y["effects"]["slot"+i]["tier"]);
			   level = y["level"];
			   p = unsafeWindow.cm.thronestats.tiers[id][tier];
			   Current = p.base + ((level * level + level) * p.growth * 0.5);
			   var quality = parseInt(y["quality"]);
				if (i<=quality) m+='<TR><TD><FONT color=black>' + Math.round(Current*100)/100 + "% " + unsafeWindow.cm.thronestats["effects"][id]["1"] + '</font></td></tr>';
				else m+='<TR><TD><FONT color=grey>' + Math.round(Current*100)/100 + "% " + unsafeWindow.cm.thronestats["effects"][id]["1"] + '</font></td></tr>';
		}
		m+="</table>"
		document.getElementById('DIV'+what).innerHTML = m;
},

ActionPopup : function(id) {
	var t = Tabs.Throne;
    var action="";
    var m = '<DIV id=pbTowrtDivF class=pbStat>Add to Enhance/Upgrade queue</div><BR><TABLE id=pbCompareStats width=100% height=0% class=pbTab>'; 
  	m+= '<TR ><TD><input id=RadioEnhance type="radio" name="actions" value="Enhance">Enhance '+ unsafeWindow.kocThroneItems[id].name +' to: <SELECT id=EnhaceItems type=list></select></td></tr>';
  	m+= '<TR><TD><input id=RadioUpgrade type="radio" name="actions" value="Upgrade">Upgrade '+ unsafeWindow.kocThroneItems[id].name +' to level: <SELECT id=UpgradeItems type=list></select></td></tr>';
  	m+= '<TR><TD align=center><INPUT id=AaddToQueue type=submit class=pbButton value="Add to queue"></td></tr></table><BR>';
  	m+= '<DIV id=pbTowrtDivF class=pbStat>Add to preset</div><BR>';
  	m+= '<DIV>Preset: <SELECT id=PresetNames type=list></select><INPUT id=AddPreset type=submit class=pbButton value="Add"></div><BR>';

  	m+= '<DIV id=pbTowrtDivF class=pbStat>Action</div><BR>';
  	m+= '<DIV align=center><INPUT id=Equip type=submit class=pbButton value="Equip item"><INPUT id=PostToChat type=submit class=pbButton value="Post to chat"></div><BR>';
  
     var pop = new pbPopup ('ActionPopup', 0, 0, 425, 300, true);
     pop.centerMe (mainPop.getMainDiv());  
     pop.getMainDiv().innerHTML = m;
     pop.getTopDiv().innerHTML = '<CENTER><B>AIO Script Throne Card Action</b></center>';
     
    
     pop.show (true);

    document.getElementById('EnhaceItems').options.length=0;
    var QualityCheck = parseInt(unsafeWindow.kocThroneItems[id].quality) +1;
	for (i=QualityCheck;i<=5;i++){
		var o = document.createElement("option");
		o.text = t.Quality[i];
		o.value = i;
		document.getElementById("EnhaceItems").options.add(o);
	}
	document.getElementById('EnhaceItems').value = 5;

	document.getElementById('UpgradeItems').options.length=0;
    var LevelCheck = 1 + parseInt(unsafeWindow.kocThroneItems[id].level);
	for (i=LevelCheck;i<=13;i++){
		var o = document.createElement("option");
		o.text = i;
		o.value = i;
		document.getElementById("UpgradeItems").options.add(o);
	}

	document.getElementById('PresetNames').options.length=0;
	for (i=1;i<=8;i++){
		var o = document.createElement("option");
		o.text = ThroneOptions.PresetName[i];
		o.value = i;
		document.getElementById("PresetNames").options.add(o);
	}
	
	document.getElementById("AaddToQueue").addEventListener ('click', function (){
		if (document.getElementById("RadioEnhance").checked) action = "Enhance";
		if (document.getElementById("RadioUpgrade").checked) action = "Upgrade";
		if (action != "") {
			if (action == "Enhance") var diff = parseInt(document.getElementById('EnhaceItems').value) - parseInt(unsafeWindow.kocThroneItems[id].quality);
			if (action == "Upgrade") var diff = parseInt(document.getElementById('UpgradeItems').value) -  parseInt(unsafeWindow.kocThroneItems[id].level);
			for (ii=0;ii<diff;ii++) ThroneOptions.Items.push ({id:parseInt(id),action:action,name:unsafeWindow.kocThroneItems[id]["name"],qualityfrom:0,qualityto:0,levelfrom:0,levelto:0,cost:0,active:false});
	    	saveThroneOptions();
	    	t.checkUpgradeInfo(false);
	    	pop.show(false);
		}    	
	},false);

	document.getElementById("Equip").addEventListener ('click', function (){
			t.doEquip(parseInt(id),"Compare");
	    	pop.show(false);
	},false);	

	document.getElementById("PostToChat").addEventListener ('click', function (){
			t.PostToChat(parseInt(id));
	    	pop.show(false);
	},false);

	document.getElementById("AddPreset").addEventListener ('click', function (){
			t.AddToPreset(parseInt(id));
	    	pop.show(false);
	},false);
     
},

TimeLeft : function(msg) {
	var t = Tabs.Throne;
	if (document.getElementById('DIV2') != undefined) document.getElementById('DIV2').innerHTML = msg;
	if (document.getElementById('PresetCont') != undefined) document.getElementById('PresetCont').innerHTML = msg;
	if (document.getElementById('ShowTrPresets') != undefined) document.getElementById('ShowTrPresets').innerHTML = msg;
},

PostToChat : function(id) {
	var t = Tabs.Throne;
	item = unsafeWindow.kocThroneItems[id];
	var msg = ":::. " + item.name + " | ";
	for (i=1;i<=5;i++) {
		id = item["effects"]["slot"+i]["id"];
		tier = parseInt(item["effects"]["slot"+i]["tier"]);
		level = item["level"];
		p = unsafeWindow.cm.thronestats.tiers[id][tier];
		Current = p.base + ((level * level + level) * p.growth * 0.5);
		var quality = parseInt(y["quality"]);
		msg += ' | ' + Math.round(Current*100)/100 + "% " + unsafeWindow.cm.thronestats["effects"][id]["1"];
    }
	sendChat ("/a "+  msg);
},

AddToPreset : function(id) {
	var t = Tabs.Throne;
	if (typeof(unsafeWindow.kocThroneItems[id]) == 'object') {
				var y = unsafeWindow.kocThroneItems[id];
		} else return;
	var type = y.type;
	if (type == "window") type = "windows";
	ThroneOptions.Presets[document.getElementById('PresetNames').value][type] = y.id;	
	saveThroneOptions();
},


PaintHistory : function() {
	var t = Tabs.Throne;
	var popHistory = null;
	popHistory = new pbPopup('pbShowHistory', 0, 0, 1100, 500, true, function() {clearTimeout (1000);});
	var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbShowBarbs" id="pbBars">';       
	popHistory.getMainDiv().innerHTML = '</table></div>' + m;
	popHistory.getTopDiv().innerHTML = '<TD><B>Succesfull Upgrade/Enhance list:</td>';
	for (i=0;i<t.log.length;i++){
		var row = document.getElementById('pbBars').insertRow(0);
		row.vAlign = 'top';
		row.style.color = "black";
		row.insertCell(0).innerHTML = t.log[i].time;
		row.insertCell(1).innerHTML = t.log[i].name;
		row.insertCell(2).innerHTML = t.log[i].action;
		row.insertCell(3).innerHTML = t.log[i].tries;
		row.insertCell(4).innerHTML = t.log[i].good;
		row.insertCell(5).innerHTML = t.log[i].bad;
	}
	var row = document.getElementById('pbBars').insertRow(0);
	row.vAlign = 'top';
	row.style.color = "black";
	row.insertCell(0).innerHTML = "Time";
	row.insertCell(1).innerHTML = "Name";
    row.insertCell(2).innerHTML = "Action";
    row.insertCell(3).innerHTML = "Tries";
    row.insertCell(4).innerHTML = "Good Req.";
	row.insertCell(5).innerHTML = "Bad Req.";
	popHistory.show(true);
},


PaintSalvageHistory : function() {
	var t = Tabs.Throne;
	var popHistory = null;
	popHistory = new pbPopup('pbSalvageShowHistory', 0, 0, 1300, 500, true, function() {clearTimeout (1000);});
	var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbShowBarbs" id="pbBars">';       
	popHistory.getMainDiv().innerHTML = '</table></div>' + m;
	popHistory.getTopDiv().innerHTML = '<TD><B>Throne room Salvage list:</td>';

	for (i=0;i<t.SalvageLog.length;i++){
		var row = document.getElementById('pbBars').insertRow(0);
		row.vAlign = 'top';
		row.style.color = "black";
		row.insertCell(0).innerHTML = t.SalvageLog[i].time;
		row.insertCell(1).innerHTML = t.SalvageLog[i].stones;
		row.insertCell(2).innerHTML = t.SalvageLog[i].item;
		
		cell = row.insertCell(3)
		if (unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot1] != undefined) {
			cell.innerHTML = unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot1][1];
			if (ThroneOptions.Salvage[t.SalvageLog[i].slot1]) cell.style.color = "red";
			if (ThroneOptions.Salvage_fav[t.SalvageLog[i].slot1]) cell.style.color = "yellow";
			
			cell = row.insertCell(4)
			cell.innerHTML = unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot2][1];
			if (ThroneOptions.Salvage[t.SalvageLog[i].slot2]) cell.style.color = "red";
			if (ThroneOptions.Salvage_fav[t.SalvageLog[i].slot2]) cell.style.color = "yellow";

			cell = row.insertCell(5)
			cell.innerHTML = unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot3][1];
			if (ThroneOptions.Salvage[t.SalvageLog[i].slot3]) cell.style.color = "red";
			if (ThroneOptions.Salvage_fav[t.SalvageLog[i].slot3]) cell.style.color = "yellow";

			cell = row.insertCell(6)
			cell.innerHTML = unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot4][1];
			if (ThroneOptions.Salvage[t.SalvageLog[i].slot4]) cell.style.color = "red";
			if (ThroneOptions.Salvage_fav[t.SalvageLog[i].slot4]) cell.style.color = "yellow";

			cell = row.insertCell(7)
			cell.innerHTML = unsafeWindow.cm.thronestats.effects[t.SalvageLog[i].slot5][1];
			if (ThroneOptions.Salvage[t.SalvageLog[i].slot5]) cell.style.color = "red";
			if (ThroneOptions.Salvage_fav[t.SalvageLog[i].slot5]) cell.style.color = "yellow";

		}	
	}
	var row = document.getElementById('pbBars').insertRow(0);
	row.vAlign = 'top';
	row.style.color = "black";
	row.insertCell(0).innerHTML = "Time";
	row.insertCell(1).innerHTML = "Aetherstones";
	row.insertCell(2).innerHTML = "Item";
	row.insertCell(3).innerHTML = "Slot1";
	row.insertCell(4).innerHTML = "Slot2";
	row.insertCell(5).innerHTML = "Slot3";
	row.insertCell(6).innerHTML = "Slot4";
	row.insertCell(7).innerHTML = "Slot5";

	popHistory.show(true)	;
},

 	addToQueue : function (id,action){
		var t= Tabs.Throne;
	 	ThroneOptions.Items.push ({id:id,action:action,name:unsafeWindow.kocThroneItems[id]["name"],qualityfrom:0,qualityto:0,levelfrom:0,levelto:0,cost:0,active:false});
	    saveThroneOptions();
        t.checkUpgradeInfo(false);
	    t.PaintQueue();
		if (ThroneOptions.Active) t.UpdateShowStatus("Starting Next Queue item...");
		 else t.UpdateShowStatus("Auto Upgrade/Enhance/Repair is OFF."); 
  },

  checkUpgradeInfo : function (firstRun){
	var t= Tabs.Throne;
    var countUpgrade = 0;
	var countEnhance = 0;
    var levelfrom = 0;
	var levelto =0;
	var qualityfrom = 0;
	var qualityto = 0;
	if (ThroneOptions.Items.length == 0) return;
    for (k=0;k<ThroneOptions.Items.length;k++){
		countUpgrade = 0;
		countEnhance = 0;
		if (unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]] != undefined) {
				if (k>0) for (l=0;l<k;l++) {
		          	if (ThroneOptions.Items[l]["id"] == ThroneOptions.Items[k]["id"] && ThroneOptions.Items[l]["action"] == "Upgrade") {countUpgrade++;}
					if (ThroneOptions.Items[l]["id"] == ThroneOptions.Items[k]["id"] && ThroneOptions.Items[l]["action"] == "Enhance") {countEnhance++;}
		      	}
				if (ThroneOptions.Items[k]["action"] == "Upgrade") {
					ThroneOptions.Items[k]["levelfrom"] = parseInt(unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]]["level"]) + countUpgrade;
					ThroneOptions.Items[k]["levelto"] = parseInt(ThroneOptions.Items[k]["levelfrom"]) +1;
						ThroneOptions.Items[k]["qualityfrom"] = parseInt(unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]]["quality"]) + countEnhance;
					if (ThroneOptions.Items[k]["levelto"]>13 && !firstRun) {logit("You can't upgrade higher then level 13!");ThroneOptions.Items.splice (k,1);return;}
				}
				if (ThroneOptions.Items[k]["action"] == "Enhance") {
					ThroneOptions.Items[k]["qualityfrom"] = parseInt(unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]]["quality"]) + countEnhance;
					ThroneOptions.Items[k]["qualityto"] = parseInt(ThroneOptions.Items[k]["qualityfrom"]) +1;
					 ThroneOptions.Items[k]["levelfrom"] = parseInt(unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]]["level"]) + countUpgrade;
					if (ThroneOptions.Items[k]["qualityto"]>5 && !firstRun) {logit("You can't upgrade higher then quality 5!");ThroneOptions.Items.splice (k,1);return;}
				}
				if (ThroneOptions.Items[k]["action"] == "Enhance") var lvl = parseInt(ThroneOptions.Items[k]["qualityfrom"]) +1;
				if (ThroneOptions.Items[k]["action"] == "Upgrade") var lvl = parseInt(ThroneOptions.Items[k]["levelfrom"]) +1;
				costAction = ThroneOptions.Items[k]["action"].toLowerCase();
				if (unsafeWindow.cm.thronestats[costAction][lvl] != undefined) ThroneOptions.Items[k]["cost"] = unsafeWindow.cm.thronestats[costAction][lvl].Stones;
				else ThroneOptions.Items.splice (k,1);
		} else ThroneOptions.Items.splice (k,1);
    }
    saveThroneOptions();
  },
    
    
	PaintQueue : function (){
		var t= Tabs.Throne;
		if (document.getElementById('ShowQueueDiv') != null) document.getElementById('ShowQueueDiv').innerHTML = '<TABLE id=ShowQueue class=pbStat align="center" width=90%></table>';
		for (k=(ThroneOptions.Items.length-1);k>=0;k--){
			if (typeof(unsafeWindow.kocThroneItems[ThroneOptions.Items[k]["id"]]) == 'object') t._addTab(k,ThroneOptions.Items[k]["name"],ThroneOptions.Items[k]["qualityfrom"],ThroneOptions.Items[k]["qualityto"],ThroneOptions.Items[k]["levelfrom"],ThroneOptions.Items[k]["levelto"],ThroneOptions.Items[k]["action"],ThroneOptions.Items[k]["active"],ThroneOptions.Items[k]["cost"]);
			else ThroneOptions.Items.splice (k,1);
		}
		t._addTabHeader();
  },
  
  doAction : function (){
        var t= Tabs.Throne;
        var now = new Date().getTime()/1000.0;
        if (!ThroneOptions.Active) return;
		if (ThroneOptions.Items.length ==0) {t.UpdateShowStatus("No items in queue!!");return;}
        ThroneOptions.Items["0"]["active"] = true;
        t.PaintQueue();
        if (unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].isBroken == true && Seed.queue_throne.end == undefined){
		          unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].isBroken = false;
		          unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].brokenType = "";
             
          		  setTimeout(t.doRepair,5000);
			    return;
        } 
        if (unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].isBroken == false && Seed.queue_throne.end == undefined){
			t.UpdateShowStatus("Doing " + ThroneOptions.Items["0"]["action"] + "...");
            if (ThroneOptions.Items["0"]["action"] == "Upgrade") setTimeout(t.doUpgrade,5000);
            if (ThroneOptions.Items["0"]["action"] == "Enhance") setTimeout(t.doEnhance,5000);
        }
  },
  
  
  doEnhance : function() {
		var t = Tabs.Throne;
		if (typeof(unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]]) == 'object') var y = unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]];
		 else return;
		var cityid = 0;
		for (var k in Cities.byID) if (parseInt(Seed.resources["city"+k]["rec5"][0]) > parseInt((ThroneOptions.Items["0"]["cost"]))) cityid = k;	
		if(cityid == 0){t.UpdateShowStatus("Not enough aetherstone to enhance!!");return;}
		var buffItem = 0; 
        if(ThroneOptions.UseTokens && y.quality >= ThroneOptions.LPSlevel) {
         	if(parseInt(unsafeWindow.seed.items['i20002'])>0) buffItem = 20002; //protection stone           	
         	if(parseInt(unsafeWindow.seed.items['i20001'])>0) buffItem = 20001;//lesser protection stone            
         	if(buffItem) unsafeWindow.cm.InventoryView.removeItemFromInventory(buffItem);
     	}
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'upgradeQuality';
		params.throneRoomItemId = ThroneOptions.Items["0"]["id"];
		params.buffItemId = buffItem;
		params.payment = "aetherstone";
		params.cityId = cityid;
		
      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					if (params.buffItemId > 0) actionLog('Used Stone on :' +unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].name+ '(Quality: '+ y.quality + ')');
				    if (rslt.gems > 0)
				    {
					    t.UpdateShowStatus('Upgrader accidentally spent gems!  Turning upgrader off!!');
					    ThroneOptions.Active = false;
					    saveThroneData();
				    }
					Seed.resources["city" + cityid]["rec5"][0] -= rslt.aetherstones;
				  	y.level = rslt.item.level;
	        		y.quality = rslt.item.quality
					y.status = rslt.item.status;
					if (rslt.success)
					{					
					   y.name = y.createName();
					   t.addToLog(ThroneOptions.Items["0"]["id"],ThroneOptions.Items["0"]["action"],ThroneOptions.Tries,ThroneOptions.Good,ThroneOptions.Bad);
					   ThroneOptions.Tries = 0;
					   ThroneOptions.Good = 0;
					   ThroneOptions.Bad = 0;
					   saveThroneOptions();
					   t.UpdateShowTries("Tries: --");
             		   ThroneOptions.Items.splice (0,1);
				    }
				    else
				    {
				       if (rslt.error_code==256) unsafeWindow.seed.throne.inventory[params.throneRoomItemId].status =3;
					   y.isBroken = true;
					   y.brokenType = "quality";
					   y.name = y.createName();
					   ThroneOptions.Tries++;
					   t.UpdateShowStatus('Enhance failed :( <br />Item: ' + unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].name +"<br />Waiting for repair...");
					   t.UpdateShowTries("Tries: " + ThroneOptions.Tries + "<br />Good requests: " + ThroneOptions.Good + "   Bad requests: " + ThroneOptions.Bad);
				    }
				    unsafeWindow.cm.ThroneView.renderInventory(unsafeWindow.kocThroneItems);
            
            		t.checkUpgradeInfo(false);
	          		t.PaintQueue();
					ThroneOptions.Good++;
					saveThroneOptions();
				} else {
					ThroneOptions.Bad++;
					saveThroneOptions();
				}
				return;	
			},
			onFailure: function () {
			   return;
			},
		});
	},
	   
	doUpgrade : function() {
		var t = Tabs.Throne;
		if (typeof(unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]]) == 'object') var y = unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]];
		 else return;
		var cityid = 0;
		for (var k in Cities.byID) if (parseInt(Seed.resources["city"+k]["rec5"][0]) > parseInt((ThroneOptions.Items["0"]["cost"]))) cityid = k;
		if(cityid == 0){t.UpdateShowStatus("Not enough aetherstone to enhance!!");return;}
		var buffItem = 0;
        if(ThroneOptions.UseTokens && y.level >= ThroneOptions.LLTlevel) {
         	if(parseInt(unsafeWindow.seed.items['i20006'])>0) buffItem = 20006;//lucky token    
         	if(parseInt(unsafeWindow.seed.items['i20005'])>0) buffItem = 20005;//lesser lucky token       
         	if(buffItem) unsafeWindow.cm.InventoryView.removeItemFromInventory(buffItem);
      	}
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'upgradeLevel';
		params.throneRoomItemId = ThroneOptions.Items["0"]["id"];
		params.buffItemId = buffItem;
		params.payment = "aetherstone";
		params.cityId = cityid;
		
      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					if (params.buffItemId > 0) actionLog('Used Token on :' +unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].name+ '(Level: '+ y.level + ')');
				    if (rslt.gems > 0)
				    {
					    t.UpdateShowStatus('Upgrader accidentally spent gems!  Turning upgrader off!!');
					    ThroneOptions.Active = false;
					    saveThroneData();
				    }
					Seed.resources["city" +cityid]["rec5"][0] -= rslt.aetherstones;
					if (rslt.success)
					{
					   y.level = rslt.item.level;
					   y.quality = rslt.item.quality;
					   y.name = y.createName();
					   t.addToLog(ThroneOptions.Items["0"]["id"],ThroneOptions.Items["0"]["action"],ThroneOptions.Tries,ThroneOptions.Good,ThroneOptions.Bad);
					   ThroneOptions.Tries = 0;
					   ThroneOptions.Good = 0;
					   ThroneOptions.Bad = 0;
					   saveThroneOptions();
					   t.UpdateShowTries("Tries: --");
             		   ThroneOptions.Items.splice (0,1);
				    }
				    else
				    {
					   y.isBroken = true;
					   y.brokenType = "level";
					   y.status = rslt.item.status;
                       y.name = y.createName();
					   ThroneOptions.Tries++;
					   saveThroneOptions();
					   t.UpdateShowStatus('Upgrade failed :( <br />Item: ' + unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].name +"<br />Waiting for repair...");
					   t.UpdateShowTries("Tries: " + ThroneOptions.Tries + "<br />Good requests: " + ThroneOptions.Good + "   Bad requests: " + ThroneOptions.Bad);
				    }
				    unsafeWindow.cm.ThroneView.renderInventory(unsafeWindow.kocThroneItems);
				
						t.checkUpgradeInfo(false);
		          		t.PaintQueue();
						ThroneOptions.Good++;
						saveThroneOptions();
				} else {
					ThroneOptions.Bad++;
					saveThroneOptions();
				}
			    return;
			},
			onFailure: function () {
			   return;
			},
		});   
	},
		
	 doRepair : function() {
		var t = Tabs.Throne;
		var cityid = 0;
		for (var k in Cities.byID) if (parseInt(Seed.resources["city"+k]["rec5"][0]) > 10000) cityid = k;
		if(cityid == 0){
		   t.UpdateShowStatus("Not enough aetherstone to repair !");
		   return;	
		}
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'timeRepair';
		params.throneRoomItemId = ThroneOptions.Items["0"]["id"];
		params.cityId = cityid;
					
		
      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
					if(rslt.ok){
              				ThroneOptions.RepairEnd = rslt.eta; 
              				var now = new Date().getTime()/1000.0;
              				t.setRepairTimer = setInterval (t.repairTimerUpdate,1000); 
				 	 		Seed.queue_throne.itemId= ThroneOptions.Items["0"]["id"];
		             		Seed.queue_throne.start=unixTime();
					 		Seed.queue_throne.end= rslt.eta;
					 		t.repairId = ThroneOptions.Items["0"]["id"];
					 		t.repairEnd = rslt.eta;
					 		unsafeWindow.cm.ThroneView.renderInventory(unsafeWindow.kocThroneItems);
					 		var x = rslt.eta - unixTime();
							ThroneOptions.Good++;
							saveThroneOptions();
				   } else {	
				   		ThroneOptions.Good++;
						saveThroneOptions();
				   }		
				   return;
			},
			onFailure: function () {
			   return;
			},
		});
    
	},


	doEquip : function(n,tab) {
		var t = Tabs.Throne;
		if (typeof(unsafeWindow.kocThroneItems[n]) == 'object') {
				var y = unsafeWindow.kocThroneItems[n];
		} else return;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'equipItem';
		params.itemId = y.id;
		params.presetId = Seed.throne.activeSlot;
		
      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
					if(rslt.ok){
							unsafeWindow.cm.ThroneView.clickItemEquip(y);
							if (tab == "Compare") {
								var msg="";
					    		for(i=1;i<=ActiveItems;i++) document.getElementById("DIV"+i).innerHTML="";
					    		for (counter=0;counter<=5;counter++){
					    			msg = '<DIV align="center"><FONT size="20"><B>Time left is : ' + (5 - counter) + '</b></font></div>';
									setTimeout(t.TimeLeft,counter*1000,msg);
								}    	    
					    		setTimeout(t.FillEquipCheckboxes,5000);
					    		if (document.getElementById("ShowTrPresets") != undefined) {
					    			if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") setTimeout(Dashboard.ShowTrPresets,5000);
									else setTimeout(Dashboard.ShowTrPresets,5000);
								}
							}
					} 
			},
			onFailure: function () {
			   return;
			},
		});
	},
  
  repairTimerUpdate :function (){
		var t = Tabs.Throne;
        if (ThroneOptions.Items.length == 0) return;
		var now = new Date().getTime()/1000.0;
        var diff = 0;
		if (Seed.queue_throne.end == undefined) return;
		else diff = Seed.queue_throne.end - now;
        if (diff <0){
            clearTimeout(t.setRepairTimer);
            if (ThroneOptions.Active) t.UpdateShowStatus("Waiting for timer...");
            else t.UpdateShowStatus("Auto Upgrade/Enhance/Repair is OFF.");
            unsafeWindow.kocThroneItems[Seed.queue_throne.itemId].isBroken = false;
            Seed.queue_throne = "";
            return;
        } else {
              t.UpdateShowStatus("Repairing on: " + unsafeWindow.kocThroneItems[ThroneOptions.Items["0"]["id"]].name + "<br/>Time left: " + timestr(diff)+ " ("+ timestr(Seed.queue_throne.end - Seed.queue_throne.start) + ")");
        	  t.UpdateShowTries("Tries: " + ThroneOptions.Tries + "<br />Good requests: " + ThroneOptions.Good + "   Bad requests: " + ThroneOptions.Bad);
		}
  
  },


paintStones : function (){
	var t = Tabs.Throne;
	m="<TABLE width=90% height=0% class=pbTab><TR><TD>Aetherstones: </td>";
	for (i=0;i<Seed.cities.length;i++) m+='<TD>' + Seed.cities[i]["1"] + '</td>';
	m+="</tr><TR><TD></td>"
	for (i=0;i<Seed.cities.length;i++) m+='<TD>' + addCommas(Seed.resources["city"+Seed.cities[i]["0"]]["rec5"][0]) + '</td>';
	m+="</tr></table>"
	if (document.getElementById('ShowStones') != null) document.getElementById('ShowStones').innerHTML = m;	
},

addToLog : function (id,action,tries,good,bad){
	var t = Tabs.Throne;
	var now = new Date();
	var time = now.getDate() +"/"+ (now.getMonth()+1) +"/"+ now.getFullYear() +"  "+ now.getUTCHours() + ":" + now.getMinutes();
	var name = unsafeWindow.kocThroneItems[id]["name"];
	t.log.push ({time:time,name:name,action:action,tries:tries,good:good,bad:bad});
	if (t.log.length > 50) t.log.splice(0,1);
	GM_setValue ('ThroneHistory_'+getServerId(), JSON2.stringify(t.log));
},


addToSalvageLog : function (item,slot1,slot2,slot3,slot4,slot5,stones){
	var t = Tabs.Throne;
	var now = new Date();
	var time =  FullDateTime(now);
	t.SalvageLog.push ({time:time,stones:stones,item:item,slot1:slot1,slot2:slot2,slot3:slot3,slot4:slot4,slot5:slot5,stones:stones});
	if (t.SalvageLog.length > 100) t.SalvageLog.splice(0,1);
	GM_setValue ('ThroneSalvageHistory_'+getServerId(), JSON2.stringify(t.SalvageLog));
},


salvageCheck : function (){
	var t = Tabs.Throne;
	var type ="";
	var NotUpgrading = true;
	var NotFavorite = true;
	var number = 0;
	var count=0;
	var NotYathzee = true;
	var Not4ofAKind = true;
	var NotFullHouse = true;
	var TypeCheck = false;
	if(!Options.ThroneDeleteItems) return;
	if (t.SalvageRunning == true) return;
	t.SalvageRunning = true;
 	for (m in unsafeWindow.kocThroneItems) {
		y = unsafeWindow.kocThroneItems[m];
		type = "";
		NotUpgrading = true;
		NotFavorite = true;
		NotYathzee = true;
		Not4ofAKind = true;
		NotFullHouse = true;	
		number = 0;
		count++;	
		if (typeof(y.id) == 'number') {
			for (k in ThroneOptions.Items) {if (ThroneOptions.Items[k]["id"] == y.id) NotUpgrading = false;}
			if (count<=(parseInt(Seed.throne.rowNum)*5) && count>ThroneOptions.saveXitems) {

					for (i=1;i<=5;i++){
							TypeCheck = false;
							if (y.type == ThroneOptions.Salvage_Type[y.effects["slot"+i].id] || "all" == ThroneOptions.Salvage_Type[y.effects["slot"+i].id] || "ALL" == ThroneOptions.Salvage_Type[y.effects["slot"+i].id]) TypeCheck = true;
							if (ThroneOptions.Salvage[y.effects["slot"+i].id] && i>=ThroneOptions.Salvage_slots[y.effects["slot"+i].id] && TypeCheck) {number++;}
							if (ThroneOptions.Salvage_fav[y.effects["slot"+i].id] && i>=ThroneOptions.Salvage_slots[y.effects["slot"+i].id] && TypeCheck) {NotFavorite= false;}			
					}
					if(ThroneOptions.thronekeep < 1) ThroneOptions.thronekeep = 1;
					if (y.effects["slot1"].id == y.effects["slot2"].id && y.effects["slot2"].id == y.effects["slot3"].id && y.effects["slot3"].id== y.effects["slot4"].id && y.effects["slot4"].id== y.effects["slot5"].id) NotYathzee = false;
					if (y.effects["slot2"].id == y.effects["slot3"].id && y.effects["slot3"].id== y.effects["slot4"].id && y.effects["slot4"].id == y.effects["slot5"].id) Not4ofAKind = false;
					if (y.effects["slot1"].id == y.effects["slot2"].id && y.effects["slot3"].id == y.effects["slot4"].id && y.effects["slot4"].id == y.effects["slot5"].id) NotFullHouse = false;

					if (number < ThroneOptions.thronekeep && NotYathzee && Not4ofAKind && NotFullHouse && NotUpgrading && NotFavorite && !y.isEquipped && !y.isBroken && t.LastDeleted != y.id) {
						if (y.level == 0) t.SalvageArray.push(y.id);
					}					 
			}
		}
	}
	if (t.SalvageArray.length == 0) t.SalvageRunning = false;
},	

doSalvage : function(){
		var t = Tabs.Throne;	
		var cityid = 0;
		var Aetherstones = [];
        for (var k in Cities.byID) {
			Aetherstones.push({city:k,astones: Seed.resources["city"+k]["rec5"][0]});
		}
		Aetherstones.sort(t.AstoneCompare);
		cityid = Aetherstones[0].city;
		if (cityid == 0) cityid = Seed.cities[0][0];
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
		params.action = 'salvage';
		params.itemId = t.SalvageArray[0];
		params.cityId = cityid;
		
      	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					y =  unsafeWindow.kocThroneItems[params.itemId];
					z = unsafeWindow.cm.thronestats.effects;
					t.addToSalvageLog(y.name,y.effects["slot1"].id,y.effects["slot2"].id,y.effects["slot3"].id,y.effects["slot4"].id,y.effects["slot5"].id,rslt.aetherstones);
					unsafeWindow.kocThroneItems[params.itemId].salvage();
				}
				else {
					t.addToSalvageLog(0,0,0,0,0,0,0);
				}
			},
			onFailure: function () {
					return;
			},
		});
		t.SalvageArray.splice(0,1);
		t.LastDeleted = params.itemId;
		if (t.SalvageArray.length == 0) t.SalvageRunning = false;
},

AstoneCompare: function (a, b) {
	  if (a.astones > b.astones) return 1;
	  else if (a.astones < b.astones) return -1;
	  return 0;
},


hide : function (){
	var t = Tabs.Throne;
	clearInterval(t.timer);
},

show : function (){
    var t = Tabs.Throne;
    if (t.curTabName == 'Sal') 
    	t.Salvage();
    else if (t.curTabName == 'UE')
    	t.Upgrade_Enhance();
	else if (t.curTabName == 'EQ')
    	t.Compare();
	else if  (t.curTabName == 'PR')
		t.Preset();
	else if  (t.curTabName == 'ST')
		t.Stats();
	else if  (t.curTabName == 'TC')
		t.Caps();
  },

}



/*************************** Tower Alert Tab ***************************
Tabs.TowerAlert={
	tabLabel: 'Tower',
	myDiv: null,
}*/


/****************************  Tower Tab  ******************************/
Tabs.tower = {
  tabOrder: 11,
  tabLabel: 'Tower',
  myDiv: null,
  generateIncomingFunc : null,
  fixTargetEnabled : false,
  secondTimer : null,
  soundPlaying : false,
  defMode : {},  
  soundRepeatTimer : null,
  soundStopTimer : null,
  towerMarches: [],
  
  init: function(div){
    var t = Tabs.tower;
    t.myDiv = div;
    if (GM_getValue ('towerMarches_'+getServerId()) != null) GM_deleteValue ('towerMarches_'+getServerId());   // remove deprecated data if it exists
 
    var m = '<DIV class=pbStat>TOWER ALERTS</div><TABLE class=pbTab><TR align=center>';

    for (var i=0; i<Cities.cities.length; i++) m += '<TD width=95><SPAN id=pbtacity_'+ i +'>' + Cities.cities[i].name + '</span></td>';
    m += '</tr><TR align=center>';
    for (var cityId in Cities.byID) m += '<TD><INPUT type=submit class=pbButton id=pbtabut_'+ cityId +' value=""></td>';
    m += '</tr><TR align=center>';
    for (var cityId in Cities.byID) m += '<TD><CENTER><INPUT id=pbattackqueue_' + cityId + ' type=submit class=pbButton value="A 0 | S 0"></center></td>';
    m += '</tr></table><BR><DIV><CENTER><INPUT id=pbSoundStop type=submit class=pbButton value="'+translate("Stop Sound Alert")+'"></center></div><DIV id=pbSwfPlayer></div>';
    m += '<BR><DIV class=pbStat>SETUP</div>';
	m += '<BR><DIV id=EmailFrame></div>';       
    m += '<BR><TABLE class=pbTab>';
    m += '<TR><TD><INPUT id=pbalertemail type=checkbox '+ (Options.alertConfig.email?'CHECKED ':'') +'/></td><TD>Send E-Mail on incoming attack (Authenticate app!!)"'
    m += '<TR><TD>&nbsp</td></tr><TR><td align=center>-</td><TD align=left>Minimum # of troops to trigger tower options: <INPUT id=pbalertTroops type=text size=7 value="'+ Options.alertConfig.minTroops +'" \> <span style="color:#800; font-weight:bold"><sup>*NEW! Controls All Tower Options</sup></span></td></tr>';
    m += '<TR><TD><INPUT id=pbalertEnable type=checkbox '+ (Options.alertConfig.aChat?'CHECKED ':'') +'/></td><TD>'+translate("Automatically post incoming attacks to alliance chat")+'.</td></tr>\
        <TR><TD></td><TD><TABLE cellpadding=0 cellspacing=0>\
            <TR><TD align=right>'+translate("Message Prefix")+': &nbsp; </td><TD><INPUT id=pbalertPrefix type=text size=60 maxlength=120 value="'+ Options.alertConfig.aPrefix +'" \></td></tr>\
            <TR><TD align=right>'+translate("Alert on scouting")+': &nbsp; </td><TD><INPUT id=pbalertScout type=checkbox '+ (Options.alertConfig.scouting?'CHECKED ':'') +'/></td></tr>\
            <TR><TD align=right>'+translate("Alert on wild attack")+': &nbsp; </td><TD><INPUT id=pbalertWild type=checkbox '+ (Options.alertConfig.wilds?'CHECKED ':'') +'/></td></tr>\
            <TR><TD align=right>'+translate("Display defend status")+': &nbsp; </td><TD><INPUT id=pbalertDefend type=checkbox '+ (Options.alertConfig.defend?'CHECKED ':'') +'/></td></tr>\
            </table></td></tr>\
        <TR><TD align=right><INPUT id=pbalertraid type=checkbox '+ (Options.alertConfig.raid?'CHECKED':'') +'/></td><TD>'+translate("Stop raids on impending")+'.</td></tr>\
    <TR><TD align=right><INPUT id=pbalertTR type=checkbox '+ (Options.alertConfig.alertTR?'CHECKED ':'') +'/></td><TD> '+translate("Toggle to TR set ")+' <INPUT id=pbalertTRset type=text size=2 maxlength=1 value="'+ Options.alertConfig.alertTRset +'"> '+translate("on impending")+'</td></tr>\
        <TR><TD><BR></td></tr>\
        <TR><TD><INPUT id=pbSoundEnable type=checkbox '+ (Options.alertSound.enabled?'CHECKED ':'') +'/></td><TD>'+translate("Play sound on incoming attack/scout")+'</td></tr>\
        <TR><TD></td><TD><DIV id=pbLoadingSwf>'+translate("Loading SWF player")+'</div><DIV style="display:none" id=pbSoundOpts><TABLE cellpadding=0 cellspacing=0>\
            <TR><TD align=right>'+translate("Sound file")+': &nbsp; </td><TD><INPUT id=pbsoundFile type=text size=40 maxlength=1000 value="'+ Options.alertSound.soundUrl +'" \>\
             &nbsp; </td><TD><INPUT id=pbSoundLoad type=submit class=pbButton value='+translate("Load")+' ><INPUT id=pbSoundDefault type=submit class=pbButton value='+translate("Default")+' ></td></tr>\
            <TR><TD align=right>'+translate("Volume")+': &nbsp; </td><TD><TABLE cellpadding=0 cellspacing=0 class=pbTab><TR valign=middle><TD><SPAN id=pbVolSlider></span></td><TD width=15></td><TD align=right id=pbVolOut>0</td></td></table></td><TD align=center><SPAN id=pbLoadStat>xx</span></td></tr>\
            <TR><TD align=right><INPUT id=pbSoundRepeat type=checkbox '+ (Options.alertSound.repeat?'CHECKED ':'') +'/></td><TD> '+translate("Repeat every")+' <INPUT id=pbSoundEvery type=text size=2 maxlength=5 value="'+ Options.alertSound.repeatDelay +'"> '+translate("minutes")+'</td></tr>\
            <TR><TD></td><TD>Play for <INPUT id=pbSoundLength type=text size=3 maxlength=5 value="'+ Options.alertSound.playLength +'"> '+translate("seconds")+'</td></tr>\
            <TR><TD></td><TD><INPUT type=submit class=pbButton value="'+translate("Play Now")+'" id=pbPlayNow></td></tr></table></div></td></tr>\
        </table><BR>';
      t.myDiv.innerHTML = m;


    t.mss = new CmatSimpleSound(SWF_PLAYER_URL, null, {height:0, width:0}, t.e_swfLoaded, 'debug=n');
    t.mss.swfPlayComplete = t.e_soundFinished;
    t.mss.swfLoadComplete = t.e_soundFileLoaded;
    unsafeWindow.matSimpleSound01 = t.mss;   // let swf find it

    t.volSlider = new SliderBar (document.getElementById('pbVolSlider'), 200, 21, 0);
    t.volSlider.setChangeListener(t.e_volChanged);
    document.getElementById('pbPlayNow').addEventListener ('click', function (){t.playSound(false)}, false);
    document.getElementById('pbSoundStop').addEventListener ('click', t.stopSoundAlerts, false);
    document.getElementById('pbSoundRepeat').addEventListener ('change', function (e){Options.alertSound.repeat = e.target.checked}, false);
    document.getElementById('pbSoundEvery').addEventListener ('change', function (e){Options.alertSound.repeatDelay = e.target.value}, false);
    document.getElementById('pbSoundLength').addEventListener ('change', function (e){Options.alertSound.playLength = e.target.value}, false);
    document.getElementById('pbSoundEnable').addEventListener ('change', function (e){Options.alertSound.enabled = e.target.checked}, false);
    document.getElementById('pbSoundStop').disabled = true;
    document.getElementById('pbalertemail').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertEnable').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertPrefix').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertScout').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertWild').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertDefend').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertTroops').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertraid').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertTR').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbalertTRset').addEventListener ('change', t.e_alertOptChanged, false);
    document.getElementById('pbsoundFile').addEventListener ('change', function (){
        Options.alertSound.soundUrl = document.getElementById('pbsoundFile').value;
        t.loadUrl (Options.alertSound.soundUrl);
      }, false);
    document.getElementById('pbSoundDefault').addEventListener ('click', function (){
        document.getElementById('pbsoundFile').value = DEFAULT_ALERT_SOUND_URL;
        Options.alertSound.soundUrl = DEFAULT_ALERT_SOUND_URL;
        t.loadUrl (DEFAULT_ALERT_SOUND_URL);
      }, false);

    for (var cityId in Cities.byID){
        var but = document.getElementById ('pbtabut_'+ cityId);
        addListener (but, cityId);
        t.defMode[cityId] =  parseInt(Seed.citystats["city" + cityId].gate);
        t.displayDefMode (cityId);
      var btnNameT = 'pbattackqueue_' + cityId;
      addTowerEventListener(cityId, btnNameT);
      }
    function addListener (but, i){
      but.addEventListener ('click', function (){t.butToggleDefMode(i)}, false);
    }
    function addTowerEventListener(cityId, name){
        document.getElementById(name).addEventListener('click', function(){
            t.showTowerIncoming(cityId);
        }, false);
    }    
  },      

  show : function (){},
  hide : function (){},
 
  loadUrl : function (url){
    var t = Tabs.tower;
    t.mss.load (1, url, true);
    document.getElementById('pbLoadStat').innerHTML = 'Loading';
  },

  e_swfLoaded : function (){
    var t = Tabs.tower;
    document.getElementById('pbLoadingSwf').style.display = 'none';
    document.getElementById('pbSoundOpts').style.display = 'inline';
    t.volSlider.setValue (Options.alertSound.volume/100);
    setTimeout (function (){
    	t.mss.setVolume (1, Options.alertSound.volume);
    	 t.loadUrl (Options.alertSound.soundUrl);
    }, 500);
    if (Options.alertSound.alarmActive && Options.alertSound.expireTime>unixTime())   
      t.soundTheAlert();
  },
  
  e_alertOptChanged : function (){
    var t = Tabs.tower;
    Options.alertConfig.email = document.getElementById('pbalertemail').checked;
    Options.alertConfig.aChat = document.getElementById('pbalertEnable').checked;
    Options.alertConfig.aPrefix=document.getElementById('pbalertPrefix').value;      
    Options.alertConfig.scouting=document.getElementById('pbalertScout').checked;      
    Options.alertConfig.wilds=document.getElementById('pbalertWild').checked;
    Options.alertConfig.defend=document.getElementById('pbalertDefend').checked;
    Options.alertConfig.raid=document.getElementById('pbalertraid').checked;
    Options.alertConfig.alertTR=document.getElementById('pbalertTR').checked;
    var trset = parseInt(document.getElementById('pbalertTRset').value);
    Options.alertConfig.alertTRset = trset;
    var mt = parseInt(document.getElementById('pbalertTroops').value);
    if (mt<1 || mt>120000){
      document.getElementById('pbalertTroops').value = Options.alertConfig.minTroops;
      document.getElementById('pbalerterr').innerHTML = '<font color=#600000><B>'+translate("INVALID")+'</b></font>';
      setTimeout (function (){document.getElementById('pbalerterr').innerHTML =''}, 2000);
      return;
    }
    Options.alertConfig.minTroops = mt;
    saveOptions();
  },
  
  e_volChanged : function (val){
    var t = Tabs.tower;
    document.getElementById('pbVolOut').innerHTML = parseInt(val*100);
    Options.alertSound.volume = parseInt(val*100);
    t.mss.setVolume (1, Options.alertSound.volume);
  },
  
  butToggleDefMode : function (cityId){
    var t = Tabs.tower;
    var mode = 1;
    if (Seed.citystats["city" + cityId].gate != 0) mode = 0;
    t.ajaxSetDefMode (cityId, mode, function (newMode){
        t.defMode[cityId] = newMode;
        t.displayDefMode (cityId);
      });
  },
      
  displayDefMode : function (cityId){
    var t = Tabs.tower;
    var but = document.getElementById('pbtabut_'+ cityId);
    if (t.defMode[cityId]){
      but.className = 'pbDefButOn';
      but.value = 'Def = ON';  
    } else {
      but.className = 'pbDefButOff';
      but.value = 'Def = OFF';  
    }  
  },
    
  eachSecond : function (){
    var t = Tabs.tower;
    for (var cityId in Cities.byID){
      if (Seed.citystats["city" + cityId].gate != t.defMode[cityId]){     // user changed def mode
        t.defMode[cityId] = Seed.citystats["city"+ cityId].gate;
        t.displayDefMode (cityId);
      }
      Options.alertConfig.raidautoswitch[cityId] = false;
    }
      var now = unixTime();
    var incomming = false;
    if (matTypeof(Seed.queue_atkinc) != 'array'){
      for (var k in Seed.queue_atkinc){   // check each incoming march
        var m = Seed.queue_atkinc[k];
        if ((m.marchType==3 || m.marchType==4) && parseIntNan(m.arrivalTime)>now){
          if (m.departureTime > Options.alertConfig.lastAttack){
            Options.alertConfig.lastAttack = m.departureTime;  
            t.newIncoming (m);
            Recall.push({marchId:k,arrivalTime:m.arrivalTime});
          }
          incomming = true;
          if (Options.alertConfig.raid){
            Options.alertConfig.raidautoswitch[m.toCityId] = true;
          }
        }
      }
    }
    if (Options.alertSound.alarmActive && (now > Options.alertSound.expireTime))
      t.stopSoundAlerts();

        t.towerMarches = [];
        for (var i = 0; i < Cities.cities.length; i++) {
            var cId = Cities.cities[i].id;
            t['attackCount_' + cId] = 0;
            t['scoutCount_' + cId] = 0;
        }
        if (matTypeof(Seed.queue_atkinc) != 'array') {
            for (var k in Seed.queue_atkinc) {
                var m = Seed.queue_atkinc[k];
                if ((m.marchType == 3 || m.marchType == 4) && parseIntNan(m.arrivalTime) > now) {
                    t.handleTowerData(m);

                }
            }
        }
        for (var i = 0; i < Cities.cities.length; i++) {
            var cId = Cities.cities[i].id;
            document.getElementById('pbattackqueue_' + cId).value = 'A ' + t['attackCount_' + cId] + ' | S ' + t['scoutCount_' + cId];
        }    
  },   
  
  e_soundFinished : function (chan){ // called by SWF when sound finishes playing
    var t = Tabs.tower;
    if (chan != 1) return;
    if (!Options.alertSound.alarmActive) document.getElementById('pbSoundStop').disabled = true;
  },

  e_soundFileLoaded : function (chan, isError){ // called by SWF when sound file finishes loading
    if (chan != 1) return;
    if (isError) document.getElementById('pbLoadStat').innerHTML = translate("Error")+"!";
     else document.getElementById('pbLoadStat').innerHTML = translate("Loaded");
  },  
  
  playSound : function (doRepeats){
    var t = Tabs.tower;
    document.getElementById('pbSoundStop').disabled = false;
    clearTimeout (t.soundStopTimer);
    clearTimeout (t.soundRepeatTimer);
    t.mss.play (1, 0);
    t.soundStopTimer = setTimeout (function(){t.mss.stop(1); t.e_soundFinished(1)}, Options.alertSound.playLength*1000);
    if (doRepeats && Options.alertSound.repeat) t.soundRepeatTimer = setTimeout (function (){t.playSound(true)}, Options.alertSound.repeatDelay*60000);
     else Options.alertSound.alarmActive = false;
  },
        
  soundTheAlert : function (){
    var t = Tabs.tower;
    Options.alertSound.alarmActive = true;
    t.playSound(true);
  },
     
  stopSoundAlerts : function (){
    var t = Tabs.tower;
    t.mss.stop (1);
    clearTimeout (t.soundStopTimer);
    clearTimeout (t.soundRepeatTimer);
    document.getElementById('pbSoundStop').disabled = true;
    Options.alertSound.alarmActive = false;
    Options.alertSound.expireTime = 0;
  },

  newIncoming : function (m){
    var t = Tabs.tower;
    var totTroops = 0;
    for (k in m.unts) totTroops += m.unts[k];
    if (totTroops < Options.alertConfig.minTroops) return;  
    t.towerPreset (m);
  },

  towerPreset : function (m){
    var t = Tabs.tower;
    if (Options.alertConfig.alertTR){
	    var currentset = Seed.throne.activeSlot
	    if (Options.alertConfig.alertTRset != currentset){
	        var preset = Options.alertConfig.alertTRset
	        Tabs.Throne.EquipKabamPreset(preset);
	    }
    }  
    t.postToChat (m);
  },    
  
  sendalert : function (m){
    var t = Tabs.tower;
    var now = unixTime();
    if (Options.alertSound.enabled){
      t.soundTheAlert(m);
      if (m.arrivalTime > Options.alertSound.expireTime)
        Options.alertSound.expireTime = m.arrivalTime;
    }
    if (Options.alertConfig.raid){
        Tabs.Raid.StopCityRaids(m.toCityId);
        Options.alertConfig.raidautoswitch[m.toCityId] = true;
    }  
  },


  ajaxSetDefMode : function (cityId, state, notify){
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.cid = cityId;
        params.state = state;
        
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/gate.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (rslt) {
                if (rslt.ok) {
                    Seed.citystats["city" + cityId].gate = state;
                    notify (state);
                }
            },
            onFailure: function () {
            }
        })
  },
  
  onUnload : function (){},

  postToChat : function (m){
    var t = Tabs.tower;
    if (DEBUG_TRACE) logit ("checkTower(): INCOMING at "+ unixTime()  +": \n"+ inspect (m, 8, 1));
    if (m.marchType == null) return; // bogus march (returning scouts)
    var target, atkType, who;
    if (m.marchType == 3){
      if (!Options.alertConfig.scouting) return;
      atkType = translate('SCOUT');
    } else if (m.marchType == 4){
      atkType = translate("ATTACK");
    } else {
      return;
    }
    var city = Cities.byID[m.toCityId];
    if ( city.tileId == m.toTileId )
      target = translate('city at')+' ('+ city.x +','+ city.y + ')';
    else {
      if (!Options.alertConfig.wilds) return;
      target = translate('wilderness');
      for (k in Seed.wilderness['city'+m.toCityId]){
        if (Seed.wilderness['city'+m.toCityId][k].tileId == m.toTileId){
          target += ' at ('+ Seed.wilderness['city'+m.toCityId][k].xCoord +','+ Seed.wilderness['city'+m.toCityId][k].yCoord + ')';
          break;
        }
      }
    }
    if (Seed.players['u'+m.pid])
      who = Seed.players['u'+m.pid].n;
    else if (m.players && m.players['u'+m.pid])
      who = m.players['u'+m.pid].n;
    else
      who = translate('Unknown');
  
    if (m.fromXCoord)
      who += ' at ('+ m.fromXCoord +','+ m.fromYCoord + ')';
    who += ' ('+getDiplomacy(m.aid)+')';
    
    var msg = '..:. | ' + Options.alertConfig.aPrefix +' || ';
    var email = "";
    
    if(m.marchStatus == 9) msg += 'The '+ atkType +' on my '+ target +' by '+ who +' has been recalled.';
     else {
     	msg += atkType +' on ' + target +' || 	By: '+ who +' || Troops (arriving in ' + unsafeWindow.timestr(parseInt(m.arrivalTime - unixTime())) +') || ';
		email += '<FONT color="red"><B>'+ atkType +'</font></b><BR>';
		email += '<BR>Taget: ' + city.name + ' ('+ city.x +','+ city.y + ')';
		email += '<BR>Attacker: ' + who;
		email += '<BR>ETA: ' + FullDateTime(m.arrivalTime);
		email += '<BR><BR><U>Troops:</u>';
	}    

    for (k in m.unts){
      var uid = parseInt(k.substr (1));
      msg += m.unts[k] +' '+ unsafeWindow.unitcost['unt'+uid][0] +', ';
      email += '<BR>'+m.unts[k]+ ' '+ unsafeWindow.unitcost['unt'+uid][0];
    }
    msg = msg.slice (0, -2);
    msg += '.';
    if ( city.tileId == m.toTileId ){
      var emb = getCityBuilding(m.toCityId, 8);
      if (emb.count == 0) msg += translate(" || My embassy has not been constructed in this kingdom.  Do not attempt to reinforce.");
      else {
        var availSlots = 0;
        for (k in Seed.queue_atkinc) if (Seed.queue_atkinc[k].marchType==2 && Seed.queue_atkinc[k].toCityId==m.toCityId && Cities.byID[Seed.queue_atkinc[k].fromCityId]==null) availSlots++;
        }
        msg += ' || Encamped: '+ availSlots +'/'+ emb.maxLevel;
        if (t.defMode[m.toCityId] == 0 && Options.alertConfig.defend==true) msg+= ' || My troops are HIDING!';
        if (t.defMode[m.toCityId] == 1 && Options.alertConfig.defend==true) msg+= ' || My troops are DEFENDING!';
        msg+= ' || My technology levels are: Fl Lv' + parseInt(Seed.tech.tch13) + ', HP Lv'+ parseInt(Seed.tech.tch15) + ', PE Lv'+ parseInt(Seed.tech.tch8) + ', MA Lv'+ parseInt(Seed.tech.tch9) + ', MM Lv'+ parseInt(Seed.tech.tch11) + ', AH Lv'+ parseInt(Seed.tech.tch12);

	    msg+= ' || TRC: ' + m.pid;
	    msg+= ' || March id: ' + m.mid;
    }    
    t.sendalert(m);
    if (!Options.alertConfig.aChat) return;
    if (SEND_ALERT_AS_WHISPER) sendChat ("/"+ Seed.player.name +' '+ msg); // Whisper to myself
    else sendChat ("/a "+  msg); // Alliance chat
    if (Options.alertConfig.email) t.sendToMail(email);    
  },

  	sendToMail: function(msg){
  		var t = Tabs.tower;
  		var content = '<BODY><HTML>' + msg + '</html></body>';
  		var data = {};
    	data.Subject ='Tower Alert ('+getServerId()+')';
    	data.Message = content; 
    	GM_xmlhttpRequest({
        	method: 'POST',
        	url: 'http://nicodebelder.eu/koc/mail.php',
        	headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',},
        	data: implodeUrlArgs(data),
        	onload: function (response) {logit(response.toSource());},
    	});
  	},

      handleTowerData: function(m){
        var t = Tabs.tower;
        var now = unixTime();
        var target, atkType, who, attackermight, allianceId, allianceName, diplomacy;
        var city = Cities.byID[m.toCityId];
        
        if (DEBUG_TRACE) logit("checkTower(): INCOMING at " + unixTime() + ": \n" + inspect(m, 8, 1));
        //ATKTYPE
        if (m.marchType == 3) {
            atkType = 'scouted';
            t['scoutCount_' + m.toCityId]++;
        }
        else
            if (m.marchType == 4) {
                atkType = 'attacked';
                t['attackCount_' + m.toCityId]++;
            }
            else {
                return;
            }
        //TARGET
        if (city.tileId == m.toTileId)
            target = 'City at ' + city.x + ',' + city.y;
        else {
            target = 'Wilderness';
            for (k in Seed.wilderness['city' + m.toCityId]) {
                if (Seed.wilderness['city' + m.toCityId][k].tileId == m.toTileId) {
                    target += ' at ' + Seed.wilderness['city' + m.toCityId][k].xCoord + ',' + Seed.wilderness['city' + m.toCityId][k].yCoord;
                    break;
                }
            }
        }
        //CITYNAME
        var cityName = Cities.byID[m.toCityId].name;
        
        //TROOPS
        var units = [];
        for (i = 0; i < 16; i++)
            units[i] = 0;
        for (k in m.unts) {
            var uid = parseInt(k.substr(1));
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Supply Troop') units[1] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Militiaman') units[2] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Scout') units[3] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Pikeman') units[4] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Swordsman') units[5] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Archer') units[6] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Cavalry') units[7] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Heavy Cavalry') units[8] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Supply Wagon') units[9] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Ballista') units[10] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Battering Ram') units[11] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Catapult') units[12] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Bloodthorn') units[13] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Executioner') units[14] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Siege Wall') units[15] = m.unts[k];
            if (unsafeWindow.unitcost['unt' + uid][0] == 'Flame Archer') units[16] = m.unts[k];
        }
        //ATTACKERS INFORMATION
        if (Seed.players['u' + m.pid]) {
            who = Seed.players['u' + m.pid].n;
            attackermight = Seed.players['u' + m.pid].m;
            allianceId = Seed.players['u' + m.pid].a;
            allianceName = Seed.allianceNames[allianceId];
            diplomacy = getDiplomacy(allianceId);
        }
        else
            if (m.players && m.players['u' + m.pid]) {
                who = m.players['u' + m.pid].n;
                attackermight = parseInt(m.players['u' + m.pid].m);
                allianceId = 'a' + m.players['u' + m.pid].a;
                allianceName = Seed.allianceNames[allianceId];
                diplomacy = getDiplomacy(allianceId);
            }
            else {
                who = 'n.A.';
                attackermight = 'n.A.';
                allianceId = 'n.A.';
                allianceName = 'n.A.';
                diplomacy = 'n.A.';
            }
        //SOURCE
        if (m.fromXCoord) var source = m.fromXCoord + ',' + m.fromYCoord;
        else var source = 'n.A.';
       
        var arrivingDatetime = new Date();
        arrivingDatetime.setTime(m.arrivalTime * 1000);
        var count = t.towerMarches.length + 1;
        t.towerMarches[count] = {
            added: now,
            cityId: m.toCityId,
            target: target,
            arrival: parseIntNan(m.arrivalTime),
            atkType: atkType,
            who: who,
            attackermight: attackermight,
            allianceName: allianceName,
            diplomacy: diplomacy,
            rtime: unsafeWindow.timestr(parseInt(m.arrivalTime - unixTime())),
            arrivingDatetime: arrivingDatetime,
            source:source,
            units: units,
        };
    },
    showTowerIncoming: function(cityId){
        var t = Tabs.tower;
        var popTowerIncoming = null;
        var cityName = Tabs.build.getCityNameById(cityId);
        
        if (t.popTowerIncoming == null) {
            t.popTowerIncoming = new pbPopup('pbtower_' + cityId, 0, 0, 820, 500, true, function() {clearTimeout (t.timer);});
        }
        t.popTowerIncoming.show(false);
        var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbTabPad" id="pbCityTowerContent">';
        t.popTowerIncoming.getMainDiv().innerHTML = '</table></div>' + m;
        t.popTowerIncoming.getTopDiv().innerHTML = '<TD width="200px"><B>'+translate("Tower Report of")+' ' + cityName + '</b></td></td>';
        t.addCityData2Pop(cityId);
        t.popTowerIncoming.show(true);
        clearTimeout (t.timer);
        t.timer = setTimeout (function() {t.showTowerIncoming(cityId)}, 5000);        
    },
    addCityData2Pop: function(cityId){
        var t = Tabs.tower;
        var rownum = 0;
        var names = ['Supply', 'Mil', 'Scout', 'Pike', 'Sword', 'Archer', 'Cav', 'Heavy', 'Wagon', 'Balli', 'Ram', 'Cat'];
        enc = {};
        numSlots = 0;
        var row = document.getElementById('pbCityTowerContent').innerHTML = "";
        if (matTypeof(Seed.queue_atkinc) != 'array') {
            for (k in Seed.queue_atkinc) {
                march = Seed.queue_atkinc[k];
                if (march.marchType == 2) {
                    ++numSlots;
                    city = march.toCityId;
                    from = march.fromPlayerId;
                    if (!enc[city])
                        enc[city] = {};
                    if (!enc[city][from])
                        enc[city][from] = [];
                    k = [];
                    k[0] = parseInt(march.knightCombat);
                    for (i = 1; i < 13; i++) {
                        if (Options.encRemaining)
                            k[i] = parseInt(march['unit' + i + 'Return']);
                        else
                            k[i] = parseInt(march['unit' + i + 'Count']);
                    }
                    k[14] = parseInt(march.marchStatus);
                    var now = unixTime();
                    k[15] = parseInt(march.destinationUnixTime) - now;
                    enc[city][from].push(k);
                }
            }
        }
        var s1 = '';
        var s2 = '';
        var s3 = '';
        var tot = [];
        var atk = [];
        for (i = 0; i < 13; i++) {
            tot[i] = 0;
            atk[i] = 0;
        }

            s1 += '<STYLE> .tot{background:#f0e0f8;} .city{background:#ffffaa;} .attack{background:#FF9999;} .own{background:#66FF66;}</style>';
            s1 += '<TABLE cellspacing=0 width=100%><TR align=right><TD align=center width=16%></td>';
            
            for (k = 0; k < names.length; k++)
                s1 += '<TD width=7%><B>' + names[k] + '</b></td>';
            s1 += '</tr>';
            dest = cityId;
            if (enc[dest]) {
                for (p in enc[dest]) {
                    try {
                        player = Seed.players['u' + p].n;
                    }
                    catch (err) {
                        player = '???';
                    }
                    for (m = 0; m < enc[dest][p].length; m++) {
                        status = '';
                        if (enc[dest][p][m][14] == 1) {
                            status = ' (' + timestr(enc[dest][p][m][15]) + ')';    
                            if (enc[dest][p][m][15] < 0)
                                status = ' (enc)';    
                            else
                                 status = ' (' + timestr(enc[dest][p][m][15]) + ')';    
                        }
                        if (enc[dest][p][m][14] == 2) {
                            status = ' (enc)';    
                        }

                        s1 += '<TR align=right><TD align=left class="city">' + player + status +'</td>'
                        for (i = 1; i < 13; i++) {
                            num = enc[dest][p][m][i];
                            s1 += '<TD class="city">' + num + '</td>';
                            tot[i] += num;
                        }
                    }
                }
            } else {
                s1 += '<TR align=right><TD align=left class="city"><B>'+translate("Reinforcment")+':</b></td>'
                for (i = 1; i < 13; i++) {
                    s1 += '<TD class="city">0</td>';
                }
                
            }
            s1 += '<TR align=right><TD colspan=14><BR></tr>';
            s1 += '<TR align=right><TD class="own" align=left><B>'+translate("Own Troops")+':</b></td>';
            //OWNTROOPS
            var ownTroops = "";
            for (r = 1; r < 13; r++) {
                cityString = 'city' + cityId;
                num = parseInt(Seed.units[cityString]['unt' + r]);
                s1 += '<TD class="own">' + num + '</td>';
                tot[r] += num;
            }
            s1 += '<TD class="city"></td><TR><TD colspan=14><BR></td></tr><TR align=right><TD class="tot" align=left><B>'+translate("Defenders")+':</b></td>';
            for (i = 1; i < 13; i++)
                s1 += '<TD class="tot">' + tot[i] + '</td>';      
            s3 += '</tr></table>';
        
        s3 += '<TD class="city"></td><TR><TD colspan=14><BR></td></tr><TR align=right><TD class="tot" align=left><B>'+translate("Incoming Attacks")+':</b></td>';
        
        var names = ['Supply', 'Mil', 'Scout', 'Pike', 'Sword', 'Archer', 'Cav', 'Heavy', 'Wagon', 'Balli', 'Ram', 'Cat'];
        if (t.towerMarches.length > 0) {
            for (k in t.towerMarches) {
                if (typeof t.towerMarches[k].atkType != 'undefined') {
                    if (t.towerMarches[k].cityId == cityId) {
                        s3 += '<TABLE cellspacing=0 width=100%><TR>';
                        
                        if (t.towerMarches[k].atkType == 'attacked') {
                            s3 += '<TD rowspan=2 width=5%><B><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_4_30.jpg?6545"></b></td>';
                        }
                        else
                            if (t.towerMarches[k].atkType == 'scouted') {
                                s3 += '<TD rowspan=2 width=5%><B><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_3_30.jpg?6545"></b></td>';
                            }
                        s3 += '<TD width=15%><B>'+translate("Location")+'</b></td>';
                        s3 += '<TD width=15%><B>'+translate("Name")+'</b></td>';
                        s3 += '<TD width=10%><B>'+translate("Source")+': </b></td><TD width=10%>' + t.towerMarches[k].source + '</td>';
                        s3 += '<TD width=10%><B>'+translate("Might")+': </b></td><TD width=10%>' + t.towerMarches[k].attackermight + '</td>';
                        s3 += '<TD width=10%><B>'+translate("Alliance")+': </b></td><TD width=10%>' + t.towerMarches[k].allianceName + '</td>';
                        s3 += '<TD width=10%><B>'+translate("State")+': </b></td><TD width=10%>' + t.towerMarches[k].diplomacy + '</td></tr>';
                        s3 += '<TR><TD width=10%  >' + t.towerMarches[k].target + '</td>';
                        s3 += '<TD  >' + t.towerMarches[k].who + '</td>';
                        s3 += '<TD><B>'+translate("Remaining")+': </b></td><TD width=10%>' + t.towerMarches[k].rtime + '</td>';
                        s3 += '<TD><B>'+translate("Arrival")+': </b></td><TD  colspan=5 width=10%>' + t.towerMarches[k].arrivingDatetime + '</td></tr>';
                        s3 += '</tr></table>';
                        s3 += '<TABLE cellspacing=0 width=100%><TR align=right><TD align=left width=16%></td>';
                        for (n = 0; n < names.length; n++)
                            s3 += '<TD width=7%><B>' + names[n] + '</b></td>';
                        s3 += '</tr><TR align=right><TD class="attack" align=left><B>Units:</td>';
                        for (u = 1; u < 13; u++) {
                            num = t.towerMarches[k].units[u];
                            s3 += '<TD class="attack">' + num + '</td>';
                            atk[u] += parseInt(num);
                        }
                        s3 += '</tr></table>';
                    }
                }
                
            }
        }
        s2 += '<TR><TD colspan=14><BR></td></tr><TR align=right><TD class="attack" align=left><B>'+translate("Attackers")+':</b></td>';
        for (a = 1; a < 13; a++) s2 += '<TD class="attack" width=7%>' + atk[a] + '</td>';
        var html = s1 + s2 + s3;
        document.getElementById('pbCityTowerContent').innerHTML = html;

    },
}

/****************************  Build Implementation  ******************************
 TODO:
     visu directly in the game of build queue elements
     <span class="leveltag" style="left:60px;">10</span>
     more todos within the code
 */

Tabs.build = {
    tabOrder: 20,
    tabLabel: 'Build',
    myDiv: null,
    timer: null,
    buildTab: null,
    koc_buildslot: null,
    currentBuildMode: null,
    buildStates: [],
    loaded_bQ: [],
    lbQ: [],
    where: 'City',
    curTabName: 'Build',
    buildMode:false,
    buildPop: null,
    popupCity: null,

    init: function(div){
        var t = Tabs.build;
        t.myDiv = div;
        t.koc_buildslot = unsafeWindow.buildslot; //save original koc function
        t.currentBuildMode = "build";
        t.buildStates = {
            running: 'OFF',
            help: false,
        };
        t.readBuildStates();
		        
        for (var i = 0; i < Cities.cities.length; i++) {
            t["bQ_" + Cities.cities[i].id] = JSON2.parse(GM_getValue('bQ_' + getServerId() + '_' + Cities.cities[i].id, '[]'));											
            if (typeof t["bQ_" + Cities.cities[i].id] == 'undefined' || (t["bQ_" + Cities.cities[i].id]) == "") {
                t["bQ_" + Cities.cities[i].id] = [];
            }
		//to do: Check for duplicates in each sub-array	
        }
		
        t.cont = div;
        var m = '<DIV id=pbBuildDivF class=pbStat>'+translate("BUILD FUNCTIONS")+'</div><TABLE id=pbbuildfunctions width=100% height=0% class=pbTab><TR>';
        m+= '<TD><INPUT class="buttonDash_'+ ((t.buildStates.running=='OFF')?'OFF':'ON') +'" id=pbBuildRunning type=submit class=pbButton value="'+translate("Auto Build")+' = '+ t.buildStates.running+'"></td>';	
        m += '<TD><INPUT id=pbBuildMode type=submit class="buttonDash_'+ (t.buildMode?'ON':'OFF') +'"  value="Build Mode = '+(t.buildMode?'ON':'OFF')+'"></td>';
        m += '<TD>'+translate("Build Type")+': <SELECT id="pbBuildType">\
                <OPTION value=build>'+translate("level up")+'</option>\
                <OPTION value=max>'+translate("level max")+'</option>\
                <OPTION value=destruct>'+translate("deconstruct")+'</option>\
                </select></td>';
        m += '<TD><INPUT id=pbHelpRequest type=checkbox '+ (t.buildStates.help?' CHECKED':'') +'\></td><TD>'+translate("Ask for help")+'?</td></tr><TR><TD></tr></table>';
        m+=' <INPUT id=pbAddToQueue type=submit class=pbButton value="Upgrade">&nbsp&nbsp<B>all&nbsp&nbsp';
        m += '<SELECT id="pbSelectType"><OPTION value=13>Barracks</option><OPTION value=5>Cottages</option><OPTION value=4>Mines</option><OPTION value=3>Quarry\'s</option><<OPTION value=999>Guardian</option></select>';
        m += '&nbsp1&nbsp level in city:&nbsp&nbsp<span id=pbCityAddLevel></b></span></td>'
        m += '<DIV id=pbBuildDivQ class=pbStat>'+translate("BUILD QUEUES")+'</div><TABLE id=pbbuildqueues width=100% height=0% class=pbentry><TR>';
        for (var i = 0; i < Cities.cities.length; i++) m += '<TD colspan=2><CENTER><B>' + Cities.cities[i].name + '</b></center></td>';
        m += '</tr><TR>';
        for (var i = 0; i < Cities.cities.length; i++) m += '<TD colspan=2><CENTER><INPUT id=pbbuild_' + Cities.cities[i].id + ' type=submit class=pbButton value="'+translate("Show")+'"></center></td>';
        m += '</tr><TR>';
        for (var i = 0; i < Cities.cities.length; i++) m += '<TD colspan=2><CENTER><INPUT id=pbCancelAll_' + Cities.cities[i].id + ' type=submit class=pbButton value="'+translate("Cancel All")+'"></center></td>';
        m += '</tr><TR>';
        
        for (var i = 0; i < Cities.cities.length; i++) {
            m += '<TD>Qc:</td><TD id=pbbuildcount_' + Cities.cities[i].id + '>' + t["bQ_" + Cities.cities[i].id].length + '</td>';
        }
        m += '</tr><TR>';
        for (var i = 0; i < Cities.cities.length; i++) {
            t['totalTime_' + Cities.cities[i].id] = 0;
            cbQ = t["bQ_" + Cities.cities[i].id];
            if (typeof cbQ != 'undefined') {
                for (var j = 0; j < cbQ.length; j++) t['totalTime_' + Cities.cities[i].id] = parseInt(t['totalTime_' + Cities.cities[i].id]) + parseInt(cbQ[j].buildingTime);
                timestring = timestr(t['totalTime_' + Cities.cities[i].id]);
            }
            m += '<TD>Tt:</td><TD id=pbbuildtotal_' + Cities.cities[i].id + '>' + timestring + '</td>';
        }
        m += '</tr></table><SPAN class=boldRed id=pbbuildError></span>';
        m += '<DIV id=pbBuildDivQ class=pbStat>STARTUP</div>';
        m +='<BR><DIV>Set Build mode ON, click on a empty spot and queue a building.</div><BR>';
        m += '<DIV id=pbBuildDivQ class=pbStat>FULL AUTO BUILD</div>';
        m +='<BR><DIV>Set Auto Build to AUTO. Full auto build will automatically upgrade the lowest building in each city.</div><BR><BR>';
        
        t.cont.innerHTML = m;
        t.Addcity = new CdispCityPicker ('pbBuildCity', document.getElementById('pbCityAddLevel'), true, null, 0);
        for (var i = 0; i < Cities.cities.length; i++) {
            var cityId = Cities.cities[i].id;
            var btnName = 'pbbuild_' + cityId;
            addQueueEventListener(cityId, btnName);
            var btn2Name = 'pbCancelAll_' + cityId;
            CancelAllEventListener(cityId, btn2Name);
            t.showBuildQueue(cityId, false);
        }
        document.getElementById('pbBuildType').addEventListener('change', function(){t.setBuildMode(this.value);}, false);
        document.getElementById('pbBuildRunning').addEventListener('click', function(){t.toggleStateRunning(this);}, false);
        document.getElementById('pbBuildMode').addEventListener('click', function(){t.toggleStateMode(this);}, false);
        document.getElementById('pbHelpRequest').addEventListener ('change', function (){t.buildStates.help = (document.getElementById('pbHelpRequest').checked);t.saveBuildStates();}, false);     
        document.getElementById('pbAddToQueue').addEventListener ('click', function (){t.LevelUp();}, false);   
        window.addEventListener('unload', t.onUnload, false);     
        function addQueueEventListener(cityId, name){document.getElementById(name).addEventListener('click', function(){t.showBuildQueue(cityId, true);}, false);}     
        function CancelAllEventListener(cityId, name){
            document.getElementById(name).addEventListener('click', function(){
                for (var i=0;i<t["bQ_" + cityId].length;i++);
                t["bQ_" + cityId] = [];
                t['totalTime_' + cityId] = 0;
                document.getElementById('pbbuildcount_' + cityId).innerHTML = 0;
                document.getElementById('pbbuildtotal_' + cityId).innerHTML = timestr(0);
            }, false);
        }
	    
    },
    LevelUp: function () {
        var t = Tabs.build;
        var cityBuildings = Seed.buildings["city" + t.Addcity.city.id];
        
        for (k in cityBuildings){
        	var id = parseInt(document.getElementById('pbSelectType').value);
        	if (id == 999 && cityBuildings['pos500'] != undefined) id = cityBuildings['pos500'][0]; 
        	if (cityBuildings[k][0] == id){
        		var cityId = t.Addcity.city.id;
        		var buildingMode = "build";
        		var buildingPos = parseInt(cityBuildings[k][2]);
        		var buildingType = parseInt(cityBuildings[k][0]);
        		var buildingAttempts = parseInt(0); 
        		var buildingLevel = parseInt(cityBuildings[k][1]);
        		var result = t.calculateQueueValues(cityId, buildingLevel, buildingType, buildingMode);
				var buildingMult = result[0];
				var buildingTime = result[1];
				var buildingId = parseInt(cityBuildings[k][3]);	
        		for (l in t["bQ_" + cityId]){
        			if (t["bQ_" + cityId][l].buildingId == buildingId) buildingLevel = parseInt((t["bQ_" + cityId][l].buildingLevel +1));
				} 
				if (buildingLevel >= 0 && buildingLevel <9) t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode);
        	}

        }
    }, 
    setBuildMode: function (type) {
        var t = Tabs.build;
        t.currentBuildMode = type;
    },    
    e_autoBuild: function(){
      var t = Tabs.build;
        document.getElementById('pbbuildError').innerHTML = '';
      if (t.buildStates.running == 'ON') {
          var now = unixTime();
          var counter= 0;
          for (var i = 0; i < Cities.cities.length; i++) {
              var cityId = Cities.cities[i].id;
              var isBusy = false;
              var qcon = Seed.queue_con["city" + cityId];
              if (matTypeof(qcon)=='array' && qcon.length>0) {
                if (parseInt(qcon[0][4]) > now)
                  isBusy = true;
                else
                  qcon.shift();   // remove expired build from queue        
              }              
              if (isBusy) {
              } else {
                 if (t["bQ_" + cityId].length > 0) { // something to do?
                      var bQi = t["bQ_" + cityId][0];   //take first queue item to build
                      counter++;
                      setTimeout(t.doOne,(counter*2500),bQi);
                 }
              }           
            }
          }
    },  
    doOne : function (bQi){
        var t = Tabs.build;
        var currentcityid = parseInt(bQi.cityId);
        var cityName = t.getCityNameById(currentcityid);
        var time = parseInt(bQi.buildingTime);
        var mult = parseInt(bQi.buildingMult);
        var attempt = parseInt(bQi.buildingAttempt);
		var bypasscheck = false;        
        var mode = bQi.buildingMode;
        var citpos = parseInt(bQi.buildingPos);
        
        if ((Seed.buildings['city' + currentcityid]["pos" + citpos] == undefined)) {
        	bypasscheck = true;
        	if (currentcityid == unsafeWindow.currentcityid) document.getElementById('slot_'+ citpos).className="blank";
        }
			
			if(!bypasscheck) {
				var l_bdgid = parseInt(bQi.buildingType); //JUST FOR CHECK
				var bdgid = parseInt(Seed.buildings['city' + currentcityid]["pos" + citpos][0]);
				//  var bdgid = 13; //FOR DEBUG
				var l_curlvl = parseInt(bQi.buildingLevel); //JUST FOR CHECK
				var curlvl = parseIntNan(Seed.buildings['city' + currentcityid]["pos" + citpos][1]);
				//  var curlvl = 8; //FOR DEBUG
				var l_bid = parseInt(bQi.buildingId); //JUST FOR CHECK
				var bid = parseInt(Seed.buildings["city" + currentcityid]["pos" + citpos][3]);
				//  var bid = 1523749; //FOR DEBUG        
				if (curlvl > 8 && mode == 'build') {
					t.cancelQueueElement(0, currentcityid, time, false);
					actionLog(translate("Queue item deleted: Building level equals 9 or higher!!!"));
					return;
				};
				if (isNaN(curlvl)) {
					t.cancelQueueElement(0, currentcityid, time, false);
					actionLog(translate("Found no correct value for current building!!!!"));
					return;
				}
				if (l_bdgid != bdgid) {
					t.cancelQueueElement(0, currentcityid, time, false);
					actionLog(translate("Building Type does not match!!!!"));
					return;
				}
				if (l_bid != bid) {
					t.cancelQueueElement(0, currentcityid, time, false);
					actionLog(translate("Building ID does not match!!!!"));
					return;
				}
				if (l_curlvl < curlvl) {
						t.cancelQueueElement(0, currentcityid, time, false);
						actionLog(translate("Queue item deleted: Building level is equal or higher!!!"));
						return;
				}
				if (l_curlvl > curlvl && mode == 'build') {
						t.requeueQueueElement(bQi);
						return;
				}
			} else {
				var l_bdgid = parseInt(bQi.buildingType); //JUST FOR CHECK
				var bdgid = l_bdgid;
				//  var bdgid = 13; //FOR DEBUG			
				var l_curlvl = parseInt(bQi.buildingLevel); //JUST FOR CHECK
				var curlvl = l_curlvl;
				//  var curlvl = 8; //FOR DEBUG
				var l_bid = parseInt(bQi.buildingId); //JUST FOR CHECK
				var bid = l_bid;
			}

            if (mode == 'destruct') {
                var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                params.cid = currentcityid;
                params.bid = "";
                params.pos = citpos;
                params.lv = curlvl - 1;
                if (curlvl >= 1) {
                    params.bid = bid;
                }
                params.type = bdgid;
                
                new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/destruct.php" + unsafeWindow.g_ajaxsuffix, {
                    method: "post",
                    parameters: params,
                    onSuccess: function(transport){
                    	var rslt = eval("(" + transport.responseText + ")");
                        if (rslt.ok) {
                            actionLog("Destructing " + unsafeWindow.buildingcost['bdg' + bdgid][0] + " at " + cityName);
                            Seed.queue_con["city" + currentcityid].push([bdgid, 0, parseInt(rslt.buildingId), unsafeWindow.unixtime(), unsafeWindow.unixtime() + rslt.timeNeeded, 0, rslt.timeNeeded, citpos]);
                            if (params.cid == unsafeWindow.currentcityid) unsafeWindow.update_bdg();
                            if (document.getElementById('pbHelpRequest').checked == true) t.bot_gethelp(params.bid, currentcityid);
                            t.cancelQueueElement(0, currentcityid, time, false);
                        } else {
                            var errmsg = unsafeWindow.printLocalError(rslt.error_code || null, rslt.msg || null, rslt.feedback || null);
                            t.requeueQueueElement(bQi);
                            document.getElementById('pbbuildError').innerHTML = errmsg;
                            logit("Destruct error: " + errmsg);
                        }
                    },
                    onFailure: function(){
                        document.getElementById('pbbuildError').innerHTML = translate("Connection Error while destructing! Please try later again");
                    }
                })
            }
            if (mode == 'build') {
                var invalid = false;
                var chk = unsafeWindow.checkreq("bdg", bdgid, curlvl); //check if all requirements are met
                for (var c = 0; c < chk[3].length; c++) {
                    if (chk[3][c] == 0) {
                        invalid = true;
                    }
                }
                if (invalid == false) {                            
                    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                    params.cid = currentcityid;
                    params.bid = "";
                    params.pos = citpos;
                    params.lv = curlvl + 1;
                    if (params.lv > 9){ //make sure that no level 10+ is built
                        t.cancelQueueElement(0, currentcityid, time, false);
                        actionLog(translate("Queue item deleted: Tryed to build level 10+ building! Please report if this happens!!!"));
                        return;
                    }
                    params.bid = ((params.lv>1)?bid:"");
                    params.type = bdgid;
                    params.pay_for_an_additional_queue=0;
                    params.permission=0;
                    
                    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/construct.php" + unsafeWindow.g_ajaxsuffix, {
                        method: "post",
                        parameters: params,
                        onSuccess: function(transport){
                        	var rslt = eval("(" + transport.responseText + ")");
                            if (rslt.ok) {
                                actionLog(translate("Building")+" " + unsafeWindow.buildingcost['bdg' + bdgid][0] + " Level " + params.lv + " at " + cityName);                                
                                Seed.resources["city" + currentcityid].rec1[0] -= parseInt(unsafeWindow.buildingcost["bdg" + bdgid][1]) * mult * 3600;
                                Seed.resources["city" + currentcityid].rec2[0] -= parseInt(unsafeWindow.buildingcost["bdg" + bdgid][2]) * mult * 3600;
                                Seed.resources["city" + currentcityid].rec3[0] -= parseInt(unsafeWindow.buildingcost["bdg" + bdgid][3]) * mult * 3600;
                                Seed.resources["city" + currentcityid].rec4[0] -= parseInt(unsafeWindow.buildingcost["bdg" + bdgid][4]) * mult * 3600;
                                Seed.citystats["city" + currentcityid].gold[0] -= parseInt(unsafeWindow.buildingcost["bdg" + bdgid][5]) * mult;
                                Seed.queue_con["city" + currentcityid].push([bdgid, curlvl + 1, parseInt(rslt.buildingId), unsafeWindow.unixtime(),  unsafeWindow.unixtime() +  rslt.timeNeeded, 0, rslt.timeNeeded, citpos]);                        
                                if (curlvl == 0) unsafeWindow.seed.buildings["city" + currentcityid]["pos" + citpos] = [bdgid, 0, citpos, rslt.buildingId];
                                if (currentcityid == unsafeWindow.currentcityid) {
                                	unsafeWindow.modal_build_show_state();
									unsafeWindow.Modal.hideModalAll();
                                    unsafeWindow.update_bdg();
                    				unsafeWindow.queue_changetab_building();
                    			}
                                if (document.getElementById('pbHelpRequest').checked == true && time > 59) t.bot_gethelp(params.bid, currentcityid);
                                t.cancelQueueElement(0, currentcityid, time, false);
                            } else {
                                var errmsg = unsafeWindow.printLocalError(rslt.error_code || null, rslt.msg || null, rslt.feedback || null);
                                if (rslt.error_code == 103 || rslt.error_code == 2) { // building has already the target level => just  delete
                                    t.cancelQueueElement(0, currentcityid, time, false);
                                    actionLog(translate("Queue item deleted: Building at this Level already exists or build process already started!"));
                                } else {
                                    t.requeueQueueElement(bQi);
                                    document.getElementById('pbbuildError').innerHTML = Cities.byID[currentcityid].name +': '+ errmsg + translate(" Item was requeued. Check for retry count.");
                                }
                                logit("Construct error: "+errmsg);
                            }
                    	},
                        onFailure: function(){
                            document.getElementById('pbbuildError').innerHTML = translate("Connection Error while building! Please try later again");
                        }
                    });
                } else {
                    t.requeueQueueElement(bQi); // requeue item if check is invalid
                }
            }
    },
    test: function(){
    	for (var h = 0; h < unsafeWindow.seed.queue_con["city" + unsafeWindow.currentcityid].length; h++) {
        var n = unsafeWindow.seed.queue_con["city" + unsafeWindow.currentcityid][h];
        var e = unsafeWindow.document.getElementById("slot_" + n[7]);
	        if (e != null) {
	            var f = n[1];
	            var c = n[2];
	            e.innerHTML = "";
	            e.className = ("inprocess");
	            var b = document.createElement("span");
	            b.className = "backgroundContainer";
	            b.innerHTML = "<span class='leveltag'>" + f + "</span><span class='currentlybuilding'></span>";
	            e.appendChild(b);
	            var p = document.createElement("span");
	            p.className = "speedupButton";
	            p.innerHTML = "<a class='inlineButton20Red' name='" + c + "' onclick='cm.BuildingSpeedupController.buildingClick(event)'><span>" + unsafeWindow.g_js_strings.commonstr.speedup + "</span></a>";
	            e.appendChild(p)
	        }
    	}
    },
    requeueQueueElement: function (bQi) {
        var t = Tabs.build;
        var cityId = bQi.cityId;
        var buildingPos = parseInt(bQi.buildingPos);
        var buildingId = parseInt(bQi.buildingId);
        var buildingLevel = parseInt(bQi.buildingLevel);
        var buildingType = parseInt(bQi.buildingType);
        var buildingTime = parseInt(bQi.buildingTime);
        var buildingMult = parseInt(bQi.buildingMult);
        var buildingAttempts = parseInt(bQi.buildingAttempts);
        var buildingMode = bQi.buildingMode;
        t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts + 1, buildingMult, buildingMode); // requeue item
        t.cancelQueueElement(0, cityId, buildingTime, false); // delete Queue Item
    },
    show: function(){       
    },
    bot_buildslot: function(c, a){
        var t = Tabs.build;
        var cityId = t.getCurrentCityId();
        var buildingPos   = c.id.split("_")[1];
        var buildingType  = parseInt(Seed.buildings['city' + cityId]["pos" + buildingPos][0]);
        var buildingLevel = parseInt(Seed.buildings['city' + cityId]["pos" + buildingPos][1]);
        var buildingId    = parseInt(Seed.buildings['city' + cityId]["pos" + buildingPos][3]);
        if (DEBUG_TRACE) logit("Pos: " + buildingPos + " Type: " + buildingType + " Level: " + buildingLevel + " Id: " + buildingId);
          var buildingAttempts = 0;
        var loaded_bQ = t["bQ_" + cityId];
        if (typeof Seed.queue_con['city' + cityId][0] != 'undefined') {
            var current_construction_pos = Seed.queue_con['city' + cityId][0][2];
        } else {
            var current_construction_pos = "";
        }
        if (loaded_bQ.length == 0 && current_construction_pos != "" ) { //check anyway if there is currently build in progess for this specific building
            if (current_construction_pos != 'NaN' && current_construction_pos == buildingId) {
                buildingLevel += 1;
            }
        } else {
            if (current_construction_pos != "" && current_construction_pos == buildingId) {
                buildingLevel += 1;
            }
            for (var i = 0; i < loaded_bQ.length; i++) { // check if there are already queue items for this building or the building is currently building
                var loadedCity = loaded_bQ[i].cityId;
                var loadedSlot = loaded_bQ[i].buildingPos;
                if (loadedSlot == buildingPos && loadedCity == cityId) {
                    buildingLevel += 1;
                }
                if (loaded_bQ[i].buildingMode == 'destruct' && loadedSlot == buildingPos && loadedCity == cityId) { // check if destrcution is already in queue
                    t.modalmessage(translate("Destruction already in Queue!"));
                    return;
                }
            }
        }
        if (t.currentBuildMode == "build") {
            if (buildingLevel >= 9) {
                t.modalmessage(translate('Due to building requirements (DI), buildings above level 9\nshould be manualy built.'));
                return;
            }
            var buildingMode = "build";
            var result = t.calculateQueueValues(cityId, buildingLevel, buildingType, buildingMode);
            var buildingMult = result[0];
            var buildingTime = result[1];
            var queueId = loaded_bQ.length;
            t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode);
            t._addTab(queueId, cityId, buildingType, buildingTime, buildingLevel, buildingAttempts, buildingMode);
        }
        if (t.currentBuildMode == "max") {
            var buildingMode = "build";
            for (var bL = buildingLevel; bL <9; bL++) {
                var queueId = loaded_bQ.length;
                var result = t.calculateQueueValues(cityId, bL, buildingType, buildingMode);
                var buildingMult = result[0];
                var buildingTime = result[1];
                queueId = queueId ;
                t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, bL, buildingAttempts, buildingMult, buildingMode);
                t._addTab(queueId, cityId, buildingType, buildingTime, bL, buildingAttempts, buildingMode);
            }
        }
        if (t.currentBuildMode == "destruct") {
            var buildingMode = "destruct";
            var result = t.calculateQueueValues(cityId, buildingLevel, buildingType, buildingMode);
            var buildingMult = result[0];
            var buildingTime = result[1];
            var queueId = loaded_bQ.length;
            t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode);
            t._addTab(queueId, cityId, buildingType, buildingTime, buildingLevel, buildingAttempts, buildingMode);
        }

    },
    calculateQueueValues: function (cityId, buildingLevel, buildingType, buildingMode) {
        var t = Tabs.build;
        var now = unixTime();
        var constructionBoost = unsafeWindow.cm.ThroneController.effectBonus(78);        
        if (buildingMode == 'build') {
            var buildingMult = Math.pow(2, buildingLevel);
        }
        if (buildingMode == 'destruct') {
            var buildingMult = Math.pow(2, buildingLevel - 2);
        }
                
        var knights = Seed.knights["city" + cityId];
        if (knights) {
            var polKniId = parseInt(Seed.leaders['city' + cityId].politicsKnightId);
            if (polKniId) {
                var polValue = parseInt(Seed.knights['city' + cityId]['knt' + polKniId].politics);
                var polBoost = parseInt(Seed.knights['city' + cityId]['knt' + polKniId].politicsBoostExpireUnixtime);
                if ((polBoost - now) > 0) {
                    polValue = parseInt(polValue * 1.25);
                }
            } else {
                polValue = 0;
            }
        } else {
            polValue = 0;
        }
        
        var buildingTime = unsafeWindow.buildingcost["bdg" + buildingType][7] * buildingMult;
        if (parseInt(buildingType) < 6 && parseInt(buildingType) > 0 && buildingMult == 1) buildingTime = 15;
        if (buildingMode == 'build') {
            buildingTime = parseInt(buildingTime / (1 + 0.005 * polValue + 0.1 * parseInt(Seed.tech.tch16)));
            if (constructionBoost>0)buildingTime = Math.round(buildingTime / (1 + (constructionBoost / 100)));
        }
        if (buildingMode == 'destruct') {
            buildingTime = buildingTime / (1 + 0.005 * polValue + 0.1 * parseInt(Seed.tech.tch16));
            if (buildingTime % 1 > 0) buildingTime = parseInt(buildingTime);
        }
        
        var result = new Array(buildingMult, buildingTime);
        return result;
    },
    bot_buildguardian: function(c, a){
        var t = Tabs.build;
        var cityId = t.getCurrentCityId();
        var buildingType  = parseInt(Seed.buildings['city' + cityId]["pos" + buildingPos][0]);
        for(i=0; i < Cities.numCities; i++){
            if(Seed.guardian[i].cityId == cityId){
                var buildingLevel = Seed.guardian[i].level;
                break;
            }
        }
        var buildingId    = parseInt(Seed.buildings['city' + cityId]["pos" + buildingPos][3]);
        if (DEBUG_TRACE) logit("Pos: " + buildingPos + " Type: " + buildingType + " Level: " + buildingLevel + " Id: " + buildingId);
          var buildingAttempts = 0;
        var loaded_bQ = t["bQ_" + cityId];
        if (typeof Seed.queue_con['city' + cityId][0] != 'undefined') {
            var current_construction_pos = Seed.queue_con['city' + cityId][0][2];
        } else {
            var current_construction_pos = "";
        }
        if (loaded_bQ.length == 0 && current_construction_pos != "" ) { //check anyway if there is currently build in progess for this specific building
            if (current_construction_pos != 'NaN' && current_construction_pos == buildingId) {
                buildingLevel += 1;
            }
        } else {
            if (current_construction_pos != "" && current_construction_pos == buildingId) {
                buildingLevel += 1;
            }
            for (var i = 0; i < loaded_bQ.length; i++) { // check if there are already queue items for this building or the building is currently building
                var loadedCity = loaded_bQ[i].cityId;
                var loadedSlot = loaded_bQ[i].buildingPos;
                if (loadedSlot == buildingPos && loadedCity == cityId) {
                    buildingLevel += 1;
                }
                if (loaded_bQ[i].buildingMode == 'destruct' && loadedSlot == buildingPos && loadedCity == cityId) { // check if destrcution is already in queue
                    t.modalmessage(translate("Destruction already in Queue!"));
                    return;
                }
            }
        }
        if (t.currentBuildMode == "build") {
            if (buildingLevel >= 9) {
                t.modalmessage(translate('Due to building requirements (DI), buildings above level 9\nshould be manualy built.'));
                return;
            }
            var buildingMode = "build";
            var result = t.calculateQueueValues(cityId, buildingLevel, buildingType, buildingMode);
            var buildingMult = result[0];
            var buildingTime = result[1];
            var queueId = loaded_bQ.length;
            t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode);
            t._addTab(queueId, cityId, buildingType, buildingTime, buildingLevel, buildingAttempts, buildingMode);
        }
        if (t.currentBuildMode == "max") {
            var buildingMode = "build";
            for (var bL = buildingLevel; bL <9; bL++) {
                var queueId = loaded_bQ.length;
                var result = t.calculateQueueValues(cityId, bL, buildingType, buildingMode);
                var buildingMult = result[0];
                var buildingTime = result[1];
                queueId = queueId ;
                t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, bL, buildingAttempts, buildingMult, buildingMode);
                t._addTab(queueId, cityId, buildingType, buildingTime, bL, buildingAttempts, buildingMode);
            }
        }
        if (t.currentBuildMode == "destruct") {
            var buildingMode = "destruct";
            var result = t.calculateQueueValues(cityId, buildingLevel, buildingType, buildingMode);
            var buildingMult = result[0];
            var buildingTime = result[1];
            var queueId = loaded_bQ.length;
            t.addQueueItem(cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode);
            t._addTab(queueId, cityId, buildingType, buildingTime, buildingLevel, buildingAttempts, buildingMode);
        }

    },
    bot_gethelp: function (f, currentcityid) {
        var t = Tabs.build;
        var city = t.getCityNameById(currentcityid);
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.bid = f;
      params.ctrl = 'AskForHelp';
      params.action = 'getHelpData';
      
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (rslt) {
            unsafeWindow.handleHelpCallback (rslt.data);
          },
          onFailure: function (rslt) {
            t.bot_gethelp (f, currentcityid);
            return;
          },
          });

      var a = Seed.queue_con["city" + currentcityid];
      var e = 0;
      var d = 0;
      for (var c = 0; c < a.length; c++) {
        if (parseInt(a[c][2]) == parseInt(f)) {
          e = parseInt(a[c][0]);
          d = parseInt(a[c][1]);
          break
        }
      }
      var b = new Array();
      b.push(["REPLACE_LeVeLbUiLdInG", d]);
      b.push(["REPLACE_BuIlDiNgNaMe", unsafeWindow.buildingcost["bdg" + e][0]]);
      b.push(["REPLACE_LeVeLiD", d]);
      b.push(["REPLACE_AsSeTiD", f]);
      var g = function(h, i) {
        unsafeWindow.continuation_95(h, i);
        if (!h) {
          var j = d > 1 ? unsafeWindow.cm.SpeedUpType.upgrade : unsafeWindow.cm.SpeedUpType.build;
          unsafeWindow.cm.ClientSideCookieManager.setCookie(j, false)
        }
      };
      unsafeWindow.common_postToProfile("95", unsafeWindow.Object.cloneFeed(unsafeWindow.template_data_95), unsafeWindow.Object.cloneFeed(unsafeWindow.actionlink_data_95), g, b)
    },
    addQueueItem: function (cityId, buildingPos, buildingType, buildingId, buildingTime, buildingLevel, buildingAttempts, buildingMult, buildingMode) {
    var t = Tabs.build;
        var lbQ = t["bQ_" + cityId];
        lbQ.push({
            cityId:             cityId,
            buildingPos:        buildingPos,
            buildingType:         buildingType,
            buildingId:         buildingId,
            buildingTime:         buildingTime,
            buildingLevel:         buildingLevel,
            buildingAttempts:     buildingAttempts,
            buildingMult:         buildingMult,
            buildingMode:         buildingMode
        });
        t.modifyTotalTime(cityId, 'increase', buildingTime); //adjust total Time
        //Paint Dashboard Build mode status icon
        // green button -> document.getElementById('buildStatus').innerHTML = '<img src=""/>';	 
        if (document.getElementById('buildStatus')) document.getElementById('buildStatus').innerHTML = '<img src=""/>';
        if (document.getElementById('buildStatus')) setTimeout (function() {document.getElementById('buildStatus').innerHTML = '<img src=""/>';}, 1000);  

    },
    modalmessage: function(message){
        var t = Tabs.build;
        var timeout = 10000;
        var content = translate("autoclose after 10sec")+"...<br><br>"
        content += message;
        unsafeWindow.Modal.showAlert(content);
        window.setTimeout('unsafeWindow.Modal.hideModal();', timeout);
    },
    modifyTotalTime: function (cityId, type, buildingTime) {
        var t = Tabs.build;
        var element = document.getElementById('pbbuildcount_' + cityId);
        var currentCount = parseInt(element.innerHTML);
        if (type == "increase") {
            t['totalTime_' + cityId] = t['totalTime_' + cityId] + buildingTime;
            var currentCount = currentCount + 1;
        }
        if (type == "decrease") {
            t['totalTime_' + cityId] = t['totalTime_' + cityId] - buildingTime;
            var currentCount = currentCount - 1;
        }
        element.innerHTML = currentCount;
        document.getElementById('pbbuildtotal_' + cityId).innerHTML = timestr(t['totalTime_' + cityId]);
    },
    hide: function(){
        var t = Tabs.build;
        clearTimeout(t.HelpTimer);
    },
    onUnload: function(){
        var t = Tabs.build;
        for (var i = 0; i < Cities.cities.length; i++) {
            if (!ResetAll) GM_setValue('bQ_' + getServerId() + '_' + Cities.cities[i].id, JSON2.stringify((t["bQ_" + Cities.cities[i].id])));
        }
        t.saveBuildStates();
    },
    _addTab: function(queueId, cityId, buildingType, buildingTime, buildingLevel, buildingAttempts, buildingMode){
        var t = Tabs.build;
        var row = document.getElementById('pbCityQueueContent').insertRow(0);
        row.vAlign = 'top';
        row.insertCell(0).innerHTML = queueId;
        if (buildingMode == "destruct") {
            row.insertCell(1).innerHTML = '<img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/bonus_att.png">';
        }
        else {
            row.insertCell(1).innerHTML = '<img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/bonus_prod.png">';
        }
        row.insertCell(2).innerHTML = unsafeWindow.buildingcost['bdg' + buildingType][0];
        row.insertCell(3).innerHTML = timestr(buildingTime);
        if (buildingMode == "destruct") {
            row.insertCell(4).innerHTML = 0;
        } else {
            row.insertCell(4).innerHTML = buildingLevel + 1; // => target Level
        }
        row.insertCell(5).innerHTML = buildingAttempts;
        row.insertCell(6).innerHTML = '<a class="button20" id="queuecancel_' + queueId + '"><span>Cancel</span></a>';
        document.getElementById('queuecancel_' + queueId).addEventListener('click', function(){
            t.cancelQueueElement(queueId, cityId, buildingTime, true);
        }, false);
    },
    cancelQueueElement: function(queueId, cityId, buildingTime, showQueue){
        var t = Tabs.build;
        var queueId = parseInt(queueId);
		if (t["bQ_" + cityId][queueId].buildingLevel==0) ClearStartUpQueue(cityId,t["bQ_" + cityId][queueId]);
        t["bQ_" + cityId].splice(queueId, 1);
        t.modifyTotalTime(cityId, 'decrease', buildingTime); //adjust total Time        
        if (showQueue == true) t.showBuildQueue(cityId, false);     
    },
    showBuildQueue: function(cityId, focus){
        var t = Tabs.build;
        clearTimeout (t.timer);
        var popBuildQueue = null;
        var cityName = t.getCityNameById(cityId);
        if (t.popBuildQueue == null) {
            t.popBuildQueue = new pbPopup('pbbuild_' + cityId, 0, 0, 350, 500, true, function() {clearTimeout (t.timer);});
        }
        var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbTabPad" id="pbCityQueueContent">';       
        t.popBuildQueue.getMainDiv().innerHTML = '</table></div>' + m;
        t.popBuildQueue.getTopDiv().innerHTML = '<TD width="200px"><B>'+translate("Build Queue of")+' ' + cityName + '</b></td><TD><INPUT id=pbOptimizeByTime type=submit class=pbButton value="'+translate("Optimize by Time")+'"></td>';
        t.paintBuildQueue(cityId);
        if (focus)
          t.popBuildQueue.show(true);
        document.getElementById('pbOptimizeByTime').addEventListener('click', function(){t.clearBuildQueue();t.paintBuildQueue(cityId, true);}, false);
        t.timer = setTimeout (function() {t.showBuildQueue(cityId, false)}, 45000);  
    },
    paintBuildQueue: function(cityId, optimize){
        var t = Tabs.build;
        var lbQ = t["bQ_" + cityId];
        if (optimize == true) {
            lbQ.sort(function(a,b){return a.buildingTime - b.buildingTime});
        }
        t["bQ_" + cityId] = lbQ;
        for (var i = 0; i < lbQ.length; i++) {
            var queueId = i;
            t._addTab(queueId, lbQ[i].cityId, lbQ[i].buildingType, lbQ[i].buildingTime, lbQ[i].buildingLevel, lbQ[i].buildingAttempts, lbQ[i].buildingMode);
        }
    },
    clearBuildQueue: function() {
        var t = Tabs.build;
        var table = document.getElementById('pbCityQueueContent');
        var rows = table.rows;
        while(rows.length)
            table.deleteRow(rows.length-1);
    },
    getCurrentCityId: function(){ // TODO maybe move as global function to the core application
        if (!unsafeWindow.currentcityid) return null;
        return unsafeWindow.currentcityid;
    },
    saveBuildStates: function(){
        var t = Tabs.build;
        var serverID = getServerId();
        GM_setValue('buildStates_' + serverID, JSON2.stringify(t.buildStates));
    },
    readBuildStates: function(){
        var t = Tabs.build;
        var serverID = getServerId();
        s = GM_getValue('buildStates_' + serverID);
        if (s != null) {
            states = JSON2.parse(s);
            for (k in states)
                t.buildStates[k] = states[k];
        }
        if (t.buildStates.running==true) t.buildStates.running = 'ON';
        if (t.buildStates.running==false) t.buildStates.running = 'OFF';
    },
    toggleStateRunning: function(obj){
        var t = Tabs.build;
        if (t.buildStates.running == 'OFF') {
            t.buildStates.running = 'ON';
            t.saveBuildStates();
            if (document.getElementById('pbBuildRunning')) {document.getElementById('pbBuildRunning').value = "Auto Build = ON";document.getElementById('pbBuildRunning').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('BuildToggle')) {document.getElementById('BuildToggle').value = "Auto Build = ON";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_ON");}
        } else if (t.buildStates.running == 'ON') {
            t.buildStates.running = 'AUTO';
            t.saveBuildStates();
            if (document.getElementById('pbBuildRunning')) {document.getElementById('pbBuildRunning').value = "Auto Build = AUTO";document.getElementById('pbBuildRunning').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('BuildToggle')) {document.getElementById('BuildToggle').value = "Auto Build = AUTO";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_ON");}
        } else if (t.buildStates.running == 'AUTO') {
            t.buildStates.running = 'OFF';
            t.saveBuildStates();
            if (document.getElementById('pbBuildRunning')) {document.getElementById('pbBuildRunning').value = "Auto Build = OFF";document.getElementById('pbBuildRunning').setAttribute("class", "buttonDash_OFF");}
        	if (document.getElementById('BuildToggle')) {document.getElementById('BuildToggle').value = "Auto Build = OFF";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_OFF");}
        }
    },
    toggleStateMode: function(obj){
        var t = Tabs.build;
        if (obj.value == translate('Build Mode = OFF')) {
            unsafeWindow.buildslot = t.startupTest; // overwrite original koc function
            var guardian = document.getElementById('citymap').getElementsByClassName('bldg_guardian_0');
            if(guardian.length >0) guardian[0].addEventListener('click', t.bot_buildguardian, false);
            if (document.getElementById('pbBuildMode')) {document.getElementById('pbBuildMode').value = "Build Mode = ON";document.getElementById('pbBuildMode').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('BuildModeToggle')) {document.getElementById('BuildModeToggle').value = "Build Mode = ON";document.getElementById('BuildModeToggle').setAttribute("class", "buttonDash_ON");}
        	t.buildMode = true;
        }
        else {
            unsafeWindow.buildslot = t.koc_buildslot; // restore original koc function
            var guardian = document.getElementById('citymap').getElementsByClassName('bldg_guardian_0');
            if(guardian.length >0) guardian[0].removeEventListener('click', t.bot_buildguardian, false);
            if (document.getElementById('pbBuildMode')) {document.getElementById('pbBuildMode').value = "Build Mode = OFF";document.getElementById('pbBuildMode').setAttribute("class", "buttonDash_OFF");}
        	if (document.getElementById('BuildModeToggle')) {document.getElementById('BuildModeToggle').value = "Build Mode = OFF";document.getElementById('BuildModeToggle').setAttribute("class", "buttonDash_OFF");}
        	t.buildMode = false;
        }
    },
    getCityNameById: function (cityId) {
    	return Cities.byID[cityId].name;      
    },
    FullAuto: function(){
    	var t = Tabs.build;
    	var Queue = {1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[]};
    	var counter=0;
    	for (var i=0;i<Seed.cities.length;i++){
    		if (Seed.queue_con['city'+Seed.cities[i][0]].length==0){
    			for (var y in Seed.buildings['city'+Seed.cities[i][0]]) if (Seed.buildings['city'+Seed.cities[i][0]][y][1]>=1 && Seed.buildings['city'+Seed.cities[i][0]][y][1]<9) Queue[i+1].push({
    				cid: 		parseInt(Seed.cities[i][0]),
    				bid: 		parseInt(Seed.buildings['city'+Seed.cities[i][0]][y][3]),
    				pos: 		parseInt(Seed.buildings['city'+Seed.cities[i][0]][y][2]),
    				lvl: 		parseInt(Seed.buildings['city'+Seed.cities[i][0]][y][1]),
    				type: 		parseInt(Seed.buildings['city'+Seed.cities[i][0]][y][0])
    			})
    		}
    	}
    	for (var i=1;i<=Seed.cities.length;i++){
    		if (Queue[i].length>0){
    			var helpArray = Queue[i];
    			helpArray = helpArray.sort(function sort(a,b) {a = a['lvl'];b = b['lvl'];return a == b ? 0 : (a < b ? -1 : 1);});
    			for (var y=0;y<helpArray.length;y++){
    				var chk = checkreq(Seed.cities[i-1][0],"bdg",helpArray[y].type,helpArray[y].lvl+1);
	    			var met = true;
	                for (var c=0;c<chk[3].length;c++) if (chk[3][c] == 0) met = false;
	                if (met) if (helpArray[y].type !=50) {
	                	counter++;
	                	setTimeout(t.BuildReq,(5000*counter),helpArray[y]);
	                	break;
	                }
	           	}
    		}
    	}
    },
    BuildReq: function(what){
    	var t = Tabs.build;
    	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.cid = what.cid;
        params.bid = what.bid;
        params.pos = what.pos;
        params.lv = what.lvl + 1;

        if (what.lvl > 9){
            actionLog("Queue item deleted: Tryed to build level 10+ building! Please report if this happens!!!");
            return;
        }
        params.type = what.type;
        params.pay_for_an_additional_queue=0;
        params.permission = 0;
        var cityName = t.getCityNameById(params.cid);
   		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/construct.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			var g = Math.pow(2, what.lvl);
					Seed.resources["city" + params.cid].rec1[0] -= parseInt(unsafeWindow.buildingcost["bdg" + params.type][1]) * g * 3600;
                    Seed.resources["city" + params.cid].rec2[0] -= parseInt(unsafeWindow.buildingcost["bdg" + params.type][2]) * g * 3600;
                    Seed.resources["city" + params.cid].rec3[0] -= parseInt(unsafeWindow.buildingcost["bdg" + params.type][3]) * g * 3600;
                    Seed.resources["city" + params.cid].rec4[0] -= parseInt(unsafeWindow.buildingcost["bdg" + params.type][4]) * g * 3600;
                    Seed.citystats["city" + params.cid].gold[0] -= parseInt(unsafeWindow.buildingcost["bdg" + params.type][5]) * g;
                    Seed.queue_con["city" + params.cid].push([params.type, params.lv, parseInt(rslt.buildingId), unsafeWindow.unixtime(),  unsafeWindow.unixtime() + rslt.timeNeeded, 0, rslt.timeNeeded, params.pos]);
                    if (params.cid == unsafeWindow.currentcityid) unsafeWindow.update_bdg();
                	unsafeWindow.Modal.hideModalAll();
    				unsafeWindow.queue_changetab_building();
    				unsafeWindow.modal_build_show_state();
                    if(rslt.updateSeed) unsafeWindow.update_seed(rslt.updateSeed);    
                    t.bot_gethelp(params.bid, params.cid);
                    actionLog("Building: "+ unsafeWindow.buildingcost['bdg' + params.type][0] + " Level " + params.lv + " at " + cityName); 
        		}
        		else actionLog('Build Error at: ' + cityName + '('+rslt.error_code+')');
      		},
    	});
    },
    startupTest:function(c,a){
    	var t = Tabs.build;
    	var buildingPos   = c.id.split("_")[1];
    	if (Seed.buildings['city'+unsafeWindow.currentcityid]['pos'+buildingPos]!=undefined) {t.bot_buildslot(c,a);return;}
        var baseurl = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/';
    	var prestige = ((Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo!="")?Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType:0);
        if (prestige==0) {
        	var BuildingArray={1:"farm_26",2:"sawmill_26",3:"quarry_26",4:"mine_26",5:"cottage_lvl1_26",6:"tavern_lvl1_26",7:"knights_hall_lvl1_gen_26",8:"embassy_lvl1_gen_26",9:"store_house_lvl1_26",10:"market_lvl1_26",11:"alchemy_lvl1_26",12:"rally_point_lvl1_gen_26",13:"barracks_lvl1_gen_26",14:"watch_tower_lvl1_gen_26",15:"blacksmith_lvl1_26",16:"workshop_lvl1_26",17:"stable_lvl1_26",18:"rest_stop_lvl1_26",20:"fey_spire_lvl1",21:"apothecary_lvl1"};
        	var cityurl = "building_icons/";
        } else {
        	if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==1){
				var cityurl = "DruidBuildingIcons/"
        		var BuildingArray={5:"build_cottage",7:"build_knightshall",8:"build_embassy",10:"build_market",11:"build_alchemy",12:"build_rally",13:"build_barracks",14:"build_watchtower",20:"build_spire",22:"build_apothecary",23:"build_barracks"};
        	} else {
				var cityurl ="";
				if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==2) var BuildingArray={5:"build_fey_cottage",7:"build_fey_knightshall",8:"build_fey_embassy",10:"build_fey_market",11:"build_fey_alchemy",12:"build_fey_rallypoint",13:"build_fey_barracks",14:"build_fey_watchtower",20:"build_fey_spire",21:"build_fey_apothecary",24:"build_barracks",25:"build_altar"};
				if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==3) var BuildingArray={5:"build_briton_cottage",7:"build_briton_knightshall",8:"build_briton_embassy",10:"build_briton_market",11:"build_briton_alchemy",12:"build_briton_rallypoint",13:"build_briton_barracks",14:"build_briton_watchtower",20:"build_briton_spire",21:"build_briton_apothecary",26:"build_barracks",27:"build_workshop"};
        	}
        }     
        var element_class = document.getElementsByClassName('buttonv2 nav h20 sel');
        var where = element_class[0].id.substr(10);     
        var m= "<TABLE class=pbTab><TR>";
        for (var i=1;i<=Seed.cities.length;i++) if (Seed.cities[i-1][0] == unsafeWindow.currentcityid) var cityNumber = i;
        var painted=[];
        var counter=0;
        if (where=='city'){        	
        	if (buildingPos==1) {
        		m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+'walls_lvl1_26.png?4568"><BR><INPUT style="width:90px" id="bid_19" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg19'][0]+'"></td>';
        		painted.push(19);
        	} else {
	        	for (var i=5;i<=21;i++) {
	        		var check = t.checkBuilding(unsafeWindow.currentcityid,i);
	        		if (BuildingArray[i] && check) {
		        		if (i!=21) m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
		        		 else {
		        		 	var normal = ((prestige==0)?"Apothecary/":"")
		        		 	m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+normal + BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
		        		}
		        		painted.push(i);
		        		counter++;
		        		if (counter%7==0) m+='</tr><TR>';        	
	        		}
	        	}
	        }
        }
        if (where=='field'){
        	if (prestige==0) {
        		for (var i=1;i<=4;i++){
        			m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
	        		painted.push(i);
	        	}
	    	} else {
	        	if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==1){
	        		for (var i=22;i<=23;i++){
        				m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
	        			painted.push(i);
	        		}
	        	} 
	        	if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==2){
	        		for (var i=24;i<=25;i++){
        				m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
	        			painted.push(i);
	        		}
	        	} 
	        	if (Seed.cityData.city[unsafeWindow.currentcityid].prestigeInfo.prestigeType==3){
	        		for (var i=26;i<=27;i++){
        				m+='<TD style="vertical-align:bottom;align:center"><img style="vertical-align:bottom;margin: 0 auto;" src="'+baseurl+cityurl+BuildingArray[i]+'.png?4568"><BR><INPUT style="width:90px" id="bid_'+i+'" type=submit class=pbButton value="'+unsafeWindow.buildingcost['bdg'+i][0]+'"></td>';
	        			painted.push(i);
	        		}
	        	} 
        	}     
        }
        m+='</tr></table><BR>';
		t.buildPop = new pbPopup ('Build_Popup', 5, 170, 740, 700, true);
		t.buildPop.getMainDiv().innerHTML = m;
		t.buildPop.getTopDiv().innerHTML = '<CENTER><B>Startup Build Queue</b></center>';
		t.buildPop.show (true);
		if (painted.length <=7) document.getElementById('Build_Popup_outer').style.height="185px";
        if (painted.length >7 && painted.length <=14) document.getElementById('Build_Popup_outer').style.height="328px";
        if (painted.length >14) document.getElementById('Build_Popup_outer').style.height="471px";
		t.popupCity = unsafeWindow.currentcityid;
		for (var y=0;y<painted.length;y++) document.getElementById('bid_'+painted[y]).addEventListener('click', function(){t.Lvl1ToQueue(buildingPos,this.id)}, false);
    },
    checkBuilding:function(cid,bid){
    	var notBuild=true;
    	if (bid==5 || bid==13) return true;
    	for (var y in Seed.buildings['city'+cid]) if (Seed.buildings['city'+cid][y][0]==bid) notBuild=false;
    	for (var i=0;i<Tabs.build["bQ_" + cid].length;i++) if (Tabs.build["bQ_" + cid][i].buildingId==bid) notBuild=false;
    	return notBuild;
    },
    Lvl1ToQueue:function(pos,id){
    	var t = Tabs.build;
 		var result = t.calculateQueueValues(unsafeWindow.currentcityid, 0, id.substr(4), "build");
		var buildingMult = result[0];
		var buildingTime = result[1];
		document.getElementById('slot_'+pos).className="inprocess";
		document.getElementById('slot_'+pos).onclick=null;
		t.addQueueItem(unsafeWindow.currentcityid, pos, id.substr(4), id.substr(4), buildingTime, 0, 0, buildingMult, "build");
		t.buildPop.show (false);
    },
}

function checkreq(currentcityid, L, A, n, E) {
    var z;
    if(E === 2) z = unsafeWindow.techcost2;
     else z = unsafeWindow.techcost;
    var F = n;
    if(L == "tch" && A != 17) F = Math.min(n, 11);
    var x = Math.pow(2, (F - 1));
    var l = new Array();
    for(var G = 0; G < 5; G++) l[G] = new Array();
    var u = new Array();
    if(L == "tch") var D = z["tch" + A][8];
     else {
        if(L == "bdg") var D = unsafeWindow.buildingcost["bdg" + A][8]
         else {
            if(L == "unt") var D = unsafeWindow.unitcost["unt" + A][8]
             else if(L == "frt") var D = unsafeWindow.fortcost["frt" + A][8] 
        }
    } if(L == "bdg" && parseInt(n) > 10 && (parseInt(A) === 19 || parseInt(A) === 12 || parseInt(A) === 16 || parseInt(A) === 15 || parseInt(A) === 17 || parseInt(A) === 11 || parseInt(A) === 18 || parseInt(A) === 8 || parseInt(A) === 9 || parseInt(A) === 1 || parseInt(A) === 2 || parseInt(A) === 3 || parseInt(A) === 4)) {
        var y = unsafeWindow.getBuildingLevel(0);
        l[0].push(unsafeWindow.g_js_strings.commonstr.construction);
        l[1].push(unsafeWindow.g_js_strings.commonstr.lv + n + " " + unsafeWindow.buildingcost.bdg0[0]);
        l[2].push(unsafeWindow.g_js_strings.commonstr.lv + y + " " + unsafeWindow.buildingcost.bdg0[0]);
        if(y >= parseInt(n)) l[3].push(1);
         else l[3].push(0);
    }
    if(D.length == null) {
        var e = Object.keys(D);
        var J = new Array();
        var v = Object.keys(Seed.buildings["city" + currentcityid]);
        for(var G = 0; G < v.length; G++) {
            var p = Seed.buildings["city" + currentcityid][v[G]];
            if(J["b" + p[0]] == null) J["b" + p[0]] = parseInt(p[1])
             else J["b" + p[0]] = (p[1] > J["b" + p[0]]) ? p[1] : J["b" + p[0]]
        }
        for(var G = 0; G < e.length; G++) {
            l[0].push(unsafeWindow.g_js_strings.commonstr.construction);
            var K = e[G].split("b")[1];
            var d = 0;
            var s = (parseInt(J[e[G]]) > 0) ? (parseInt(J[e[G]])) : 0;
            var g = unsafeWindow.buildingcost["bdg" + K][0];
            if(parseInt(D[e[G]][0]) == 1) {
                d = parseInt(D[e[G]][1])
            } else {
                d = Math.min(unsafeWindow.buildingmaxlvl[K], n + parseInt(D[e[G]][1]))
            } if(L == "tch") {
                var t = [9, 15, 16, 17],
                    H = [5, 9, 12, 14];
                if(H.indexOf(parseInt(A)) != -1 && t.indexOf(parseInt(K)) != -1 && parseInt(n) == 11) {
                    d--
                } else {
                    if(parseInt(K) == 11) d = Math.max(d, n);
                }
            }
            l[1].push(unsafeWindow.g_js_strings.commonstr.lv + d + " " + g);
            l[2].push(unsafeWindow.g_js_strings.commonstr.lv + s + " " + g);
            if(s < d) l[3].push(0);
             else l[3].push(1);  
            l[4].push(null)
        }
    }
    var I = new Array();
    if(L == "tch") var a = z["tch" + A][9]
     else {
        if(L == "bdg") {
            var a = unsafeWindow.buildingcost["bdg" + A][9]
        } else {
            if(L == "unt") var a = unsafeWindow.unitcost["unt" + A][9]
             else if(L == "frt") var a = unsafeWindow.fortcost["frt" + A][9]
        }
    }
    var j = Object.keys(a);
    if(a.length == null) {
        for(var G = 0; G < j.length; G++) {
            l[0].push(unsafeWindow.g_js_strings.commonstr.research);
            var o = j[G].split("t")[1];
            var c = 0;
            var r = parseInt(Seed.tech["tch" + o]);
            var B = z["tch" + o][0];
            if(parseInt(a[j[G]][0]) == 1) {
                c = parseInt(a[j[G]][1])
            } else {
                c = n + parseInt(a[j[G]][1])
            } if(L == "bdg" && unsafeWindow.getBuildingLevel(A) === 10 && parseInt(A, 10) !== 18) {
                c = 10
            }
            l[1].push(unsafeWindow.g_js_strings.commonstr.lv + c + " " + B);
            l[2].push(unsafeWindow.g_js_strings.commonstr.lv + r + " " + B);
            if(r < c) l[3].push(0)
             else l[3].push(1)
            l[4].push(null)
        }
    }
    if(L == "tch") {
        var w = parseInt(z["tch" + A][5]) * x
    } else {
        if(L == "bdg") {
            var w = parseInt(unsafeWindow.buildingcost["bdg" + A][5]) * x;
        } else {
            if(L == "unt") var w = parseInt(unsafeWindow.unitcost["unt" + A][5]) * x;
             else if(L == "frt") var w = parseInt(unsafeWindow.fortcost["frt" + A][5]) * x;
        }
    } if(w > 0) {
        l[0].push(unsafeWindow.resourceinfo.rec0);
        var k = parseInt(Seed.citystats["city" + currentcityid].gold[0]);
        l[1].push(w);
        l[2].push(k);
        if(k < w) l[3].push(0)
         else l[3].push(1)   
        l[4].push(null)
    }
    for(var G = 1; G < 5; G++) {
        if(L == "tch") {
            var m = parseInt(z["tch" + A][G]) * x * 3600
        } else {
            if(L == "bdg") {
                var m = parseInt(unsafeWindow.buildingcost["bdg" + A][G]) * x * 3600
            } else {
                if(L == "unt") {
                    var h = unsafeWindow.cm.BlessingSystemModel.applyBlessing(unsafeWindow.cm.BlessingSystemModel.getBlessing().MORE_WITH_LESS, currentcityid, {unitid: A});
                    var m = Math.ceil(parseInt(unsafeWindow.unitcost["unt" + A][G]) * h) * x * 3600
                } else {
                    if(L == "frt") var m = parseInt(unsafeWindow.fortcost["frt" + A][G]) * x * 3600
                }
            }
        } if(m > 0) {
            l[0].push(unsafeWindow.resourceinfo["rec" + G]);
            var f = parseInt(Seed.resources["city" + currentcityid]["rec" + G][0]);
            l[1].push(parseInt(parseInt(m) / 3600));
            l[2].push(parseInt(parseInt(f) / 3600));
            if(f < m) l[3].push(0)
             else l[3].push(1)
            switch(G) {
                case 1:
                    l[4].push("Food");
                    break;
                case 2:
                    l[4].push("Wood");
                    break;
                case 3:
                    l[4].push("Stone");
                    break;
                case 4:
                    l[4].push("Ore");
                    break
            }
        }
    }
    if(L == "tch") {
        var b = parseInt(z["tch" + A][6]) * x
    } else {
        if(L == "bdg") {
            var b = parseInt(unsafeWindow.buildingcost["bdg" + A][6]) * x
        } else {
            if(L == "unt") {
                var q = unsafeWindow.cm.BlessingSystemModel.applyBlessing(unsafeWindow.cm.BlessingSystemModel.getBlessing().MORE_WITH_LESS, currentcityid, {
                    unitid: A
                });
                var b = Math.ceil(parseInt(unsafeWindow.unitcost["unt" + A][6]) * q) * x
            } else {
                if(L == "frt") {
                    var b = parseInt(unsafeWindow.fortcost["frt" + A][6]) * x
                }
            }
        }
    } if(b > 0) {
        l[0].push(unsafeWindow.g_js_strings.commonstr.population);
        var C = parseInt(Seed.citystats["city" + currentcityid].pop[0]) - parseInt(Seed.citystats["city" + currentcityid].pop[3]);
        l[1].push(b);
        l[2].push(C);
        if(C < b) l[3].push(0)
         else l[3].push(1)
        l[4].push("Population")
    }
    return l
}

function PaintStartUpQueue(cityId){
	for (var y=1;y<=32;y++) if (document.getElementById('slot_'+y)) document.getElementById('slot_'+y).onclick= function(){unsafeWindow.buildslot(this,unsafeWindow.event);return false;}; 
	for (var y=100;y<=139;y++) if (document.getElementById('slot_'+y)) document.getElementById('slot_'+y).onclick= function(){unsafeWindow.buildslot(this,unsafeWindow.event);return false;}; 
    for (var i=0;i<Tabs.build["bQ_" + cityId].length;i++){
    	if (Tabs.build["bQ_" + cityId][i].buildingLevel==0) {
    		document.getElementById('slot_'+Tabs.build["bQ_" + cityId][i].buildingPos).className="inprocess";
			document.getElementById('slot_'+Tabs.build["bQ_" + cityId][i].buildingPos).onclick=null;
    	} 
    }
}

function ClearStartUpQueue(cityId,item){
    	document.getElementById('slot_'+item.buildingPos).className="blank";
		document.getElementById('slot_'+item.buildingPos).onclick= function(){unsafeWindow.buildslot(this,unsafeWindow.event);return false;};    
}

/****************************  Transport Implementation  *******************************/
Tabs.transport = {
    tabOrder: 101,
    tabLabel: 'Transport',
    myDiv: null,
    timer: null,
    traderState: [],
    lTR: [],
    tradeRoutes: [],
    checkdotradetimeout: null,
    count: 0,
    check: false,
    rallypointlevel:0,
    init: function (div) {
        var t = Tabs.transport;
        t.myDiv = div;
        t.traderState = {running: false,};
        t.readTraderState();
        t.readTradeRoutes();
        var m = '<DIV id=pbTowrtDivF class=pbStat>' + translate("AUTOMATED TRANSPORT FUNCTION") + '</div><TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center">';
        m +='<TD><INPUT class="buttonDash_'+ (t.traderState.Running?'ON':'OFF') +'" id=pbTraderState type=submit value="'+translate("Transport")+' = '+ (t.traderState.Running?'ON':'OFF')+'"></td>';
        m += '<TD><INPUT id=pbShowRoutes type=submit class=pbButton value="' + translate("Show Routes") + '"></td>';
        m += '</tr></table></div>';
        m += '<DIV id=pbTraderDivDRoute class=pbStat>' + translate("TRADE ROUTE OPTIONS") + '</div>';
        m += '<TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center"><TR align="left">';
        m += '<TD colspan=4>' + translate("Check transport every:") + ' <INPUT id=pbtransportinterval type=text size=2 value="' + Options.transportinterval + '"\> ' + translate("minutes") + '</td></tr></table>';
        m += '<TD colspan=4>' + translate("Do not send transport out if less than") + ' <INPUT id=pbminwagons type=text size=2 value="' + Options.minwagons + '"\> ' + translate("troops are needed. (Needless transports are skipped this way)") + '</td></tr></table>';
        m += '<DIV style="margin-top:10px;margin-bottom:5px;">' + translate("If the \"trade\" amount is 0 then it will transport the max amount above \"keep\". Gold only if there is space left...") + '</div></table>';
        m += '<DIV id=pbTraderDivDRoute class=pbStat>' + translate("TRANSPORTS") + '</div>';
        m += '<TABLE id=pbaddtraderoute width=95% height=0% class=pbTab><TR align="left">';
        m += '<TR align="left"><TD>' + translate("From City:") + '</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptrescity></span></div></td></tr>';
        m += '<TR align="left">';
        m += '<TD>' + translate("To City:") + '</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptcityTo></span></div></td>';
        m += '<TD>' + translate("OR") + '</td>';
        m += '<TD>X:<INPUT id=ptcityX type=text size=3\></td>';
        m += '<TD>Y:<INPUT id=ptcityY type=text size=3\></td></tr>';
        m += '<TABLE id=pbaddtraderoute height=0% class=pbTab><TR align="left">';
        m += '<TD width=75px>TroopType:</td><TD width=150px><SELECT id="TransportTroop">';
        for (y in unsafeWindow.unitcost) m += '<option value="' + y + '">' + unsafeWindow.unitcost[y][0] + '</option>';
        m += '</select></td><TD width=75px>' + translate("Troops Available:") + '&nbsp;</td><TD id=TroopAmount align=left width=75px></td>';
        m += '<TD width=75px>' + translate("Global Carry Amount:") + '&nbsp;</td><TD id=CarryAmount align=left width=75px></td>';
        m += '<TR><TD >' + translate("Troops:") + ' </td><TD><INPUT id=TroopsToSend type=text size=6 maxlength=6 value="0">&nbsp;&nbsp;<INPUT id=MaxTroops type=submit class=pbButton value="Max"></td>';
        m += '<TD width=50px><INPUT id=FillInMax type=submit class=pbButton value="<----"></td>';
        m += '<TD id=Calc colspan=3></td></tr>';
        m += '<TABLE id=pbaddtraderoute height=0% class=pbTab><TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png"></td>';
        m += '<TD id=TransRec1 align=right width=110px></td>';
        m += '<TD id=HaveRec1 align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipFood type=checkbox unchecked=true\></td>';
        m += '<TD width=180px  align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountFood type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountFood type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxFood type=submit class=pbButton value="Max"></td></tr>';
        m += '<TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png"></td>';
        m += '<TD id=TransRec2 align=right width=110px></td>';
        m += '<TD id=HaveRec2 align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipWood type=checkbox unchecked=true\></td>';
        m += '<TD width=180px align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountWood type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountWood type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxWood type=submit class=pbButton value="Max"></td></tr>';
        m += '<TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png"></td>';
        m += '<TD id=TransRec3 align=right width=110px></td>';
        m += '<TD id=HaveRec3 align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipStone type=checkbox unchecked=true\></td>';
        m += '<TD width=180px align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountStone type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountStone type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxStone type=submit class=pbButton value="Max"></td></tr>';
        m += '<TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png"></td>';
        m += '<TD id=TransRec4 align=right width=110px></td>';
        m += '<TD id=HaveRec4 align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipOre type=checkbox unchecked=true\></td>';
        m += '<TD width=180px align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountOre type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountOre type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxOre type=submit class=pbButton value="Max"></td></tr>';
        m += '<TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png"></td>';
        m += '<TD id=TransRec5 align=right width=110px></td>';
        m += '<TD id=HaveRec5 align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipAstone type=checkbox unchecked=true\></td>';
        m += '<TD width=180px align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountAstone type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountAstone type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxAstone type=submit class=pbButton value="Max"></td></tr>';
        m += '<TR align="center">';
        m += '<TD width=5%><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png"></td>';
        m += '<TD id=TransGold align=right width=110px></td>';
        m += '<TD id=HaveGold align=right width=110px></td>';
        m += '<TD width=55px align=right><INPUT id=pbshipGold type=checkbox unchecked=true\></td>';
        m += '<TD width=180px align=left>' + translate("Keep:") + ' <INPUT id=pbtargetamountGold type=text size=11 maxlength=20 value="0" disabled=true\></td>';
        m += '<TD width=100px>' + translate("Trade:") + ' <INPUT id=pbtradeamountGold type=text size=11 maxlength=20 value="0"\></td>';
        m += '<TD width=50px><INPUT id=MaxGold type=submit class=pbButton value="Max"></td></tr>';
        m += '</table>';
        m += '<DIV style="text-align:center; margin-top:15px"><INPUT id=pbSaveRoute type=submit class=pbButton value="' + translate("Add Route") + '"><INPUT id=pbManualSend type=submit class=pbButton value="' + translate("Manual Transport") + '"><INPUT id=pbTransportToMarch type=submit class=pbButton value="' + translate("Add to march tab") + '"></div>';
        m += '<DIV id=errorSpace></div>';
        m +='<BR><DIV id=TransportInfo></div>';

        t.myDiv.innerHTML = m;
        document.getElementById('TransportTroop').value = 'unt9';
        t.tcp = new CdispCityPicker('pttrader', document.getElementById('ptrescity'), true, t.updateResources, 0);
        t.tcpto = new CdispCityPicker('pttraderTo', document.getElementById('ptcityTo'), true, t.clickCitySelect);
        t.tcpto.bindToXYboxes(document.getElementById('ptcityX'), document.getElementById('ptcityY'));
        document.getElementById('TransportTroop').addEventListener('change', function () {t.updateTroops();}, false);
        document.getElementById('pbTraderState').addEventListener('click', function () {t.toggleTraderState(this);}, false);
        document.getElementById('pbSaveRoute').addEventListener('click', function () {t.addTradeRoute();}, false);
        document.getElementById('pbManualSend').addEventListener('click', function () {t.ManualTransport();}, false);
        document.getElementById('pbTransportToMarch').addEventListener('click', function () {t.GetCoords();}, false);
        document.getElementById('pbShowRoutes').addEventListener('click', function () {t.showTradeRoutes();}, false);
        document.getElementById('FillInMax').addEventListener('click', function () {document.getElementById('TroopsToSend').value = t.TroopsNeeded;}, false);
        document.getElementById('MaxTroops').addEventListener('click', function () {
            var rallypointlevel = t.getRallypoint('city' + t.tcp.city.id);
            var max = rallypointlevel * 10000;
            var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    		if (TR > 150) TR=150;
			if (Seed.cityData.city[t.tcp.city.id].isPrestigeCity) {
	    		switch(parseInt(Seed.cityData.city[t.tcp.city.id].prestigeInfo.prestigeLevel)){
	    			case 1: max = Math.round(max * 1.50);break;
	    			case 2: max = Math.round(max * 1.60);break;
	    			case 3: max = Math.round(max * 1.65);break;
            case 4: max = Math.round(max * 1.70);break;
case 5: max = Math.round(max * 1.75);break;
case 6: max = Math.round(max * 1.80);break;
    			}
    		}
    		max+=Math.round(max * (TR / 100));
    		if (t.Troops < max) max = t.Troops;
            document.getElementById('TroopsToSend').value = max; 
        }, false);
       
        
        document.getElementById('MaxFood').addEventListener('click', function () {
            t.Food = 0;
 			var input = t.MaxClicked();
            document.getElementById('pbtradeamountFood').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransRec1').innerHTML)) ? input : parseIntCommas(document.getElementById('TransRec1').innerHTML);
        }, false);
        document.getElementById('MaxWood').addEventListener('click', function () {
            t.Wood = 0;
            var input = t.MaxClicked();
            document.getElementById('pbtradeamountWood').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransRec2').innerHTML)) ? input : parseIntCommas(document.getElementById('TransRec2').innerHTML);
        }, false);
        document.getElementById('MaxStone').addEventListener('click', function () {
            t.Stone = 0;
            var input = t.MaxClicked();
            document.getElementById('pbtradeamountStone').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransRec3').innerHTML)) ? input : parseIntCommas(document.getElementById('TransRec3').innerHTML);
        }, false);
        document.getElementById('MaxOre').addEventListener('click', function () {
            t.Ore = 0;
            var input = t.MaxClicked();
            document.getElementById('pbtradeamountOre').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransRec4').innerHTML)) ? input : parseIntCommas(document.getElementById('TransRec4').innerHTML);
        }, false);
        document.getElementById('MaxGold').addEventListener('click', function () {
            t.Gold = 0;
            var input = t.MaxClicked();
            document.getElementById('pbtradeamountGold').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransGold').innerHTML)) ? input : parseIntCommas(document.getElementById('TransGold').innerHTML);
        }, false);
        document.getElementById('MaxAstone').addEventListener('click', function () {
            t.Astone = 0;
            var input = t.MaxClicked();
            document.getElementById('pbtradeamountAstone').value = (parseInt(input) <= parseIntCommas(document.getElementById('TransRec5').innerHTML)) ? input : parseIntCommas(document.getElementById('TransRec5').innerHTML);
        }, false);
        document.getElementById('pbtransportinterval').addEventListener('keyup', function () {
            if (isNaN(document.getElementById('pbtransportinterval').value)) document.getElementById('pbtransportinterval').value = 60;
            Options.transportinterval = document.getElementById('pbtransportinterval').value;
            saveOptions();
        }, false);
        document.getElementById('pbtargetamountFood').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountFood').value)) document.getElementById('pbtargetamountFood').value = 0;}, false);
        document.getElementById('pbtargetamountWood').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountWood').value)) document.getElementById('pbtargetamountWood').value = 0;}, false);
        document.getElementById('pbtargetamountStone').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountStone').value)) document.getElementById('pbtargetamountStone').value = 0;}, false);
        document.getElementById('pbtargetamountOre').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountOre').value)) document.getElementById('pbtargetamountOre').value = 0;}, false);
        document.getElementById('pbtargetamountAstone').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountAstone').value)) document.getElementById('pbtargetamountAstone').value = 0;}, false);
        document.getElementById('pbtargetamountGold').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtargetamountGold').value)) document.getElementById('pbtargetamountGold').value = 0;}, false);
        document.getElementById('pbtradeamountFood').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountFood').value)) document.getElementById('pbtradeamountFood').value = 0;}, false);
        document.getElementById('pbtradeamountWood').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountWood').value)) document.getElementById('pbtradeamountWood').value = 0;}, false);
        document.getElementById('pbtradeamountStone').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountStone').value)) document.getElementById('pbtradeamountStone').value = 0;}, false);
        document.getElementById('pbtradeamountOre').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountOre').value)) document.getElementById('pbtradeamountOre').value = 0;}, false);
        document.getElementById('pbtradeamountAstone').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountAstone').value)) document.getElementById('pbtradeamountAstone').value = 0;}, false);
        document.getElementById('pbtradeamountGold').addEventListener('change', function () {if (isNaNCommas(document.getElementById('pbtradeamountGold').value)) document.getElementById('pbtradeamountGold').value = 0;}, false);
        document.getElementById('pbminwagons').addEventListener('keyup', function () {
        	if (isNaN(document.getElementById('pbminwagons').value)) document.getElementById('pbminwagons').value = 100;
            Options.minwagons = parseInt(document.getElementById('pbminwagons').value);
            saveOptions();
        }, false)
        document.getElementById('pbshipFood').addEventListener('click', function () {
            if (document.getElementById('pbshipFood').checked == false) document.getElementById('pbtargetamountFood').disabled = true;
             else document.getElementById('pbtargetamountFood').disabled = false;
        }, false);
        document.getElementById('pbshipWood').addEventListener('click', function () {
            if (document.getElementById('pbshipWood').checked == false) document.getElementById('pbtargetamountWood').disabled = true;
            else document.getElementById('pbtargetamountWood').disabled = false;
        }, false);
        document.getElementById('pbshipStone').addEventListener('click', function () {
            if (document.getElementById('pbshipStone').checked == false) document.getElementById('pbtargetamountStone').disabled = true;
            else document.getElementById('pbtargetamountStone').disabled = false;
        }, false);
        document.getElementById('pbshipOre').addEventListener('click', function () {
            if (document.getElementById('pbshipOre').checked == false) document.getElementById('pbtargetamountOre').disabled = true;
             else document.getElementById('pbtargetamountOre').disabled = false;
        }, false);
        document.getElementById('pbshipAstone').addEventListener('click', function () {
            if (document.getElementById('pbshipAstone').checked == false) document.getElementById('pbtargetamountAstone').disabled = true;
             else document.getElementById('pbtargetamountAstone').disabled = false;
        }, false);
        document.getElementById('pbshipGold').addEventListener('click', function () {
            if (document.getElementById('pbshipGold').checked == false) document.getElementById('pbtargetamountGold').disabled = true;
             else document.getElementById('pbtargetamountGold').disabled = false;
        }, false);
        window.addEventListener('unload', t.onUnload, false);
    },

    MaxClicked: function(){
    	var t = Tabs.transport;
    	var unit_number = document.getElementById('TroopsToSend').value;
        var unitid = document.getElementById('TransportTroop').value;
        unitid = unitid.substr(3);	
        var MaxLoad = getMaxLoad(unitid,unit_number);
		var input = MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
		return input;
    },

     GetCoords : function (){
	    var t= Tabs.transport;
	    var targetName = "";
	    var targetCityName = "";
	    var total=0;
	    var units = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	    targetX = parseInt(document.getElementById ('ptcityX').value);
	    targetY = parseInt(document.getElementById ('ptcityY').value);
	    if (targetX =="" && targetY=="") {alert("Please enter coords...");return;}
	    var what = document.getElementById('TransportTroop').value;
	    what = what.substr(3);
	    if (parseInt(document.getElementById('TroopsToSend')) == 0) {alert("You got to send a least one troop...");return;}
	    units[what] = parseInt(document.getElementById('TroopsToSend').value);	

	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.blocks = "bl_" + targetX + "_bt_" + targetY;
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			if (rslt.data["l_"+targetX+"_t_"+targetY].tileType == 51) {
        				userId = rslt.data["l_"+targetX+"_t_"+targetY].tileUserId;
        				if (userId != null) targetName = rslt.userInfo["u" + userId]["n"];
        				targetCityName = rslt.data["l_"+targetX+"_t_"+targetY].cityName;
        			}
        			MarchOptions.Queue.push ({
        				city: 			t.tcp.city.id,
        				action: 		1,
        				targetX: 		targetX,
        				targetY: 		targetY,
        				tileType: 		rslt.data["l_"+targetX+"_t_"+targetY].tileType,
        				tileLevel: 		rslt.data["l_"+targetX+"_t_"+targetY].tileLevel,
        				targetCityName: targetCityName,
        				targetName: 	targetName,
        				cityNumber: 	rslt.data["l_"+targetX+"_t_"+targetY].cityNum,
        				1: 				units[1],
        				2: 				units[2],
        				3: 				units[3],
        				4: 				units[4],
        				5: 				units[5],
        				6: 				units[6],
        				7: 				units[7],
        				8: 				units[8],
        				9: 				units[9],
        				10: 			units[10],
        				11: 			units[11],
        				12: 			units[12],
        				13: 			units[13],
        				14: 			units[14],
        				15: 			units[15],
        				r1: 			parseInt(document.getElementById ('pbtradeamountFood').value),
        				r2: 			parseInt(document.getElementById ('pbtradeamountWood').value),
        				r3: 			parseInt(document.getElementById ('pbtradeamountStone').value),
        				r4: 			parseInt(document.getElementById ('pbtradeamountOre').value),
        				r5: 			parseInt(document.getElementById ('pbtradeamountAstone').value),
        				gold: 			parseInt(document.getElementById ('pbtradeamountGold').value)
        			});
					saveMarchOptions();
					document.getElementById('TroopsToSend').value = 0;
					document.getElementById ('pbtradeamountFood').value == 0;
				    document.getElementById ('pbtradeamountWood').value == 0;
				    document.getElementById ('pbtradeamountStone').value == 0;
				    document.getElementById ('pbtradeamountOre').value == 0;
				    document.getElementById ('pbtradeamountAstone').value == 0;
				    document.getElementById ('pbtradeamountGold').value == 0;
					Dashboard.ShowMarches();
        		}
      		},
    	});
		
	},

  
    updateResources: function () {
        var t = Tabs.transport;
        var ToCity = null;
        for (var i = 1; i <= 5; i++)
        if (i == 5) document.getElementById('TransRec' + i).innerHTML = addCommas(parseInt(Seed.resources["city" + t.tcp.city.id]['rec' + i][0]));
        else document.getElementById('TransRec' + i).innerHTML = addCommas(parseInt(Seed.resources["city" + t.tcp.city.id]['rec' + i][0] / 3600));
        document.getElementById('TransGold').innerHTML = addCommas(parseInt(Seed.citystats["city" + t.tcp.city.id]['gold'][0]));
        for (ii in Seed.cities) if (Seed.cities[ii][2] == document.getElementById('ptcityX').value && Seed.cities[ii][3] == document.getElementById('ptcityY').value) ToCity = Seed.cities[ii][0];
        for (var i = 1; i <= 5; i++) if (ToCity != null) if (i == 5) document.getElementById('HaveRec' + i).innerHTML = addCommas(parseInt(Seed.resources["city" + ToCity]['rec' + i][0]));
        else document.getElementById('HaveRec' + i).innerHTML = addCommas(parseInt(Seed.resources["city" + ToCity]['rec' + i][0] / 3600));
        else document.getElementById('HaveRec' + i).innerHTML = "----";
        if (ToCity != null) document.getElementById('HaveGold').innerHTML = addCommas(parseInt(Seed.citystats["city" + ToCity]['gold'][0]));
        else document.getElementById('HaveGold').innerHTML = "----";
    },
    updateTroops: function (city) {
        var t = Tabs.transport;
        var fontcolor = 'black';
        t.Food = parseIntCommas(document.getElementById('pbtradeamountFood').value);
        t.Wood = parseIntCommas(document.getElementById('pbtradeamountWood').value);
        t.Stone = parseIntCommas(document.getElementById('pbtradeamountStone').value);
        t.Ore = parseIntCommas(document.getElementById('pbtradeamountOre').value);
        t.Gold = parseIntCommas(document.getElementById('pbtradeamountGold').value);
        t.Astone = parseIntCommas(document.getElementById('pbtradeamountAstone').value)*5;
        var unit = document.getElementById('TransportTroop').value;
        t.Troops = parseInt(Seed.units['city' + t.tcp.city.id][unit]);
        var unit_number = parseInt(document.getElementById('TroopsToSend').value);
        var unitid = document.getElementById('TransportTroop').value;
        unitid = unitid.substr(3);
        var LoadUnit = getMaxLoad(unitid,1);
        var GlobalMaxLoad = t.Troops * LoadUnit;
        t.MaxLoad = getMaxLoad(unitid,unit_number);
        t.TroopsNeeded = (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone) / LoadUnit;
        t.TroopsNeeded = t.TroopsNeeded.toFixed(0);
        if (t.TroopsNeeded < ((t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone) / LoadUnit)) t.TroopsNeeded++;
        if (t.TroopsNeeded > t.Troops) fontcolor = 'red';
        if (t.Troops > 0) document.getElementById('TroopAmount').innerHTML = '<FONT color=' + fontcolor + '>' + addCommas(t.Troops) + '</font>';
        else document.getElementById('TroopAmount').innerHTML = 0;
        if (GlobalMaxLoad > 0) document.getElementById('CarryAmount').innerHTML = addCommas(GlobalMaxLoad);
        else document.getElementById('CarryAmount').innerHTML = 0;
        document.getElementById('Calc').innerHTML = '' + translate("Resources:") + ' ' + addCommas(t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone) + ' / ' + addCommas(t.MaxLoad) + '&nbsp;&nbsp;(' + translate("Troops Needed:") + ' <FONT color=' + fontcolor + '>' + addCommas(t.TroopsNeeded) + '</font> )';
    },
    getRallypoint: function(cityId){
      var t = Tabs.transport;
      for (var o in Seed.buildings[cityId]){
        var buildingType = parseInt(Seed.buildings[cityId][o][0]);
        var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
        if (buildingType == 12) var rallypointlevel=parseInt(buildingLevel);
       }
     	if(rallypointlevel == 11) rallypointlevel = 15;
     	if(rallypointlevel == 12) rallypointlevel = 20;
     	return rallypointlevel;      
 	},

    delTradeRoutes: function () {Tabs.transport.tradeRoutes = [];},

    checkcoords: function (obj) {
        var t = Tabs.transport;
        if (obj.id == 'pbok') {
            t.check = true;
            t.addTradeRoute();
        }
        return;
    },
    addTradeRoute: function () {
        var valid = true;
        var t = Tabs.transport;
        var city = t.tcp.city.id;
        if (document.getElementById('ptcityX').value == 0 && document.getElementById('ptcityY').value == 0 && !t.check) {
            new CdialogConfirm('<SPAN class=boldRed>' + translate("You are about to set a route to location 0,0!") + '</span>', t.checkcoords, unsafeWindow.modal_attack_check, mainPop.getMainDiv);
            return;
        }
        var ship_Food = document.getElementById('pbshipFood').checked;
        var ship_Wood = document.getElementById('pbshipWood').checked;
        var ship_Stone = document.getElementById('pbshipStone').checked;
        var ship_Ore = document.getElementById('pbshipOre').checked;
        var ship_Astone = document.getElementById('pbshipAstone').checked;
        var ship_Gold = document.getElementById('pbshipGold').checked;
        var target_Food = parseIntCommas(document.getElementById('pbtargetamountFood').value);
        var target_Wood = parseIntCommas(document.getElementById('pbtargetamountWood').value);
        var target_Stone = parseIntCommas(document.getElementById('pbtargetamountStone').value);
        var target_Ore = parseIntCommas(document.getElementById('pbtargetamountOre').value);
        var target_Astone = parseIntCommas(document.getElementById('pbtargetamountAstone').value);
        var target_Gold = parseIntCommas(document.getElementById('pbtargetamountGold').value);
        var trade_Food = parseIntCommas(document.getElementById('pbtradeamountFood').value);
        var trade_Wood = parseIntCommas(document.getElementById('pbtradeamountWood').value);
        var trade_Stone = parseIntCommas(document.getElementById('pbtradeamountStone').value);
        var trade_Ore = parseIntCommas(document.getElementById('pbtradeamountOre').value);
        var trade_Astone = parseIntCommas(document.getElementById('pbtradeamountAstone').value);
        var trade_Gold = parseIntCommas(document.getElementById('pbtradeamountGold').value);
        var target_x = document.getElementById('ptcityX').value;
        var target_y = document.getElementById('ptcityY').value;
        var target_city = 0;
        var TroopType = document.getElementById('TransportTroop').value;
        var route_state = true;
        if (t.tcpto.city) if (t.tcpto.city.x == target_x && t.tcpto.city.y == target_y) target_city = t.tcpto.city.id;
        if (valid == true) {
            var lTR = t.tradeRoutes;
            lTR.push({
                city: city,
                ship_Food: ship_Food,
                target_Food: target_Food,
                trade_Food: trade_Food,
                ship_Wood: ship_Wood,
                target_Wood: target_Wood,
                trade_Wood: trade_Wood,
                ship_Stone: ship_Stone,
                target_Stone: target_Stone,
                trade_Stone: trade_Stone,
                ship_Ore: ship_Ore,
                target_Ore: target_Ore,
                trade_Ore: trade_Ore,
                ship_Astone: ship_Astone,
                target_Astone: target_Astone,
                trade_Astone: trade_Astone,
                ship_Gold: ship_Gold,
                target_Gold: target_Gold,
                trade_Gold: trade_Gold,
                target_x: target_x,
                target_y: target_y,
                target_city: target_city,
                TroopType: TroopType,
                route_state: "true"
            });
        }
        document.getElementById('pbTraderDivDRoute').style.background = '#99FF99';
        setTimeout(function () {(document.getElementById('pbTraderDivDRoute').style.background = '');}, 1000);
    },
    showTradeRoutes: function () {
        var t = Tabs.transport;
        var popTradeRoutes = null;
        t.popTradeRoutes = new pbPopup('pbShowTrade', 0, 0, 750, 485, true, function () {clearTimeout(1000);});
        var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbTab" id="pbRoutesQueue">';
        t.popTradeRoutes.getMainDiv().innerHTML = '</table></div>' + m;
        t.popTradeRoutes.getTopDiv().innerHTML = '<TD><CENTER><B>' + translate("Transport routes") + '</b></center></td>';
        t.paintTradeRoutes();
        t.popTradeRoutes.show(true);
    },
    paintTradeRoutes: function () {
        var t = Tabs.transport;
        var r = t.tradeRoutes;
        var cityname;
        var m = '<TABLE id=paintRoutes class=pbTab>';
        for (var i = 0; i < (r.length); i++) {
            var queueId = i;
            var cityname = (Cities.byID[r[queueId].city] ? Cities.byID[r[queueId].city].name : "null");
            var citynameTo = null, TO, status, unit;
            if (typeof r[queueId].target_city != 'undefined' && parseInt(r[queueId].target_city) > 0) citynameTo = Cities.byID[r[queueId].target_city].name;
            if (citynameTo == null) TO = r[i].target_x + ',' + r[i].target_y;
            else TO = citynameTo;
            if (r[i].route_state) status = '<FONT color=green>' + translate("Enabled") + '</font>';
            else status = '<FONT color=red>' + translate("Disabled") + '</font>';
            if (r[i].TroopType == undefined) unit = 'unt9';
            else unit = r[i].TroopType;
            m += '<TR><TD TD width=12px>&nbsp;&nbsp;</td></tr>';
            m += '<TR><TD width=20px>' + (i + 1) + '</td><TD width=175px>' + translate("From:") + '&nbsp;&nbsp;' + cityname + '</TD><TD width=175px>' + translate("To:") + '&nbsp;&nbsp;' + TO + '</td><TD width=175px>' + status + '</td>';
            m += '<TD width=60px><A onclick="traceEdit(' + queueId + ')">' + translate("Edit") + '</a></td><TD width=60px><A onclick="traceDelete(' + queueId + ')">Delete</a></td></tr>';
            m += '<TR><TD></td><TD>Troops:&nbsp;&nbsp;' + unsafeWindow.unitcost[unit][0] + '</td></tr>';
            if (r[i].ship_Food) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Food) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Food) + '</td>';
            if (r[i].ship_Wood) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Wood) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Wood) + '</td>';
            if (r[i].ship_Stone) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Stone) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Stone) + '</td>';
            if (r[i].ship_Ore) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Ore) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Ore) + '</td>';
            if (r[i].ship_Astone) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Astone) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Astone) + '</td>';
            if (r[i].ship_Gold) m += '<TR><TD></td><TD align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png"></td><TD>' + translate("Target:") + ' ' + addCommas(r[i].target_Gold) + '</td><TD>' + translate("Trade:") + ' ' + addCommas(r[i].trade_Gold) + '</td>';
        }
        m += '</table>';
        document.getElementById('pbRoutesQueue').innerHTML = m;
        unsafeWindow.traceEdit = t.editQueueElement;
        unsafeWindow.traceDelete = t.cancelQueueElement;
    },
    cancelQueueElement: function (queueId) {
        var t = Tabs.transport;
        var queueId = parseInt(queueId);
        t.tradeRoutes.splice(queueId, 1);
        t.showTradeRoutes();
    },
    editQueueElement: function (queueId) {
        var t = Tabs.transport;
        var r = t.tradeRoutes;
        var queueId = parseInt(queueId);
        var cityname = Cities.byID[r[queueId].city].name;
        var citynameTo, TO;
        if (typeof r[queueId].target_city != 'undefined' || parseInt(r[queueId].target_city) > 0) if (Cities.byID[r[queueId].target_city]) citynameTo = Cities.byID[r[queueId].target_city].name;
        var Types = ['food', 'wood', 'stone', 'iron', 'aetherstone', 'gold'];
        if (citynameTo == null) TO = r[queueId].target_x + ',' + r[queueId].target_y;
        else TO = citynameTo;
        var n = '<TABLE id=editRoutes class=pbTab>';
        n += '<TD>' + translate("From:") + '&nbsp;' + cityname + '</td><TD>' + translate("To:") + '&nbsp;' + TO + '</td>';
        n += '<TD><INPUT id=TradeStatus type=checkbox>&nbsp;Enable Route</td>';
        n += '<TD width=150px>' + translate("Troop Type:") + '<SELECT id="pbbTransportTroop">';
        for (y in unsafeWindow.unitcost) n += '<option value="' + y + '">' + unsafeWindow.unitcost[y][0] + '</option>';
        n += '</select></td></table><BR><TABLE  id=editRoutes class=pbTab>';
        for (var i = 0; i < Types.length; i++) {
            var icon = Types[i];
            n += '<TR><TD width=50px align=center><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/' + icon + '_50.jpg?6545?6545"></td>';
            n += '<TD width=50px align=center><INPUT id=pbbship' + icon + ' type=checkbox></td>';
            n += '<TD width=125px>' + translate("Keep:") + ' <INPUT id=pbbtargetamount' + icon + ' type=text size=11 maxlength=11 value="0"></td>';
            n += '<TD width=125px>' + translate("Trade:") + ' <INPUT id=pbbtradeamount' + icon + ' type=text size=11 maxlength=11 value="0"\></td></tr>';
        }
        n += '</table><BR><TABLE id=editRoutes class=pbTab><TR><TD><a class="button20" id="Cancel"><span>' + translate("Cancel") + '</span></a></td>';
        n += '<TD><a class="button20" id="Save"><span>' + translate("Save") + '</span></a></td></tr>';
        n += '</table>';
        document.getElementById('pbRoutesQueue')
            .innerHTML = n;
        document.getElementById('TradeStatus')
            .checked = r[queueId].route_state;
        if (r[queueId].TroopType == undefined) var unit = 'unt9';
        else var unit = r[queueId].TroopType;
        document.getElementById('pbbTransportTroop').value = unit;
        document.getElementById('pbbshipfood').checked = r[queueId].ship_Food;
        document.getElementById('pbbshipwood').checked = r[queueId].ship_Wood;
        document.getElementById('pbbshipstone').checked = r[queueId].ship_Stone;
        document.getElementById('pbbshipiron').checked = r[queueId].ship_Ore;
        document.getElementById('pbbshipaetherstone').checked = r[queueId].ship_Astone;
        document.getElementById('pbbshipgold').checked = r[queueId].ship_Gold;
        document.getElementById('pbbtargetamountfood').value = r[queueId].target_Food;
        document.getElementById('pbbtargetamountwood').value = r[queueId].target_Wood;
        document.getElementById('pbbtargetamountstone').value = r[queueId].target_Stone;
        document.getElementById('pbbtargetamountiron').value = r[queueId].target_Ore;
        document.getElementById('pbbtargetamountaetherstone').value = r[queueId].target_Astone;
        document.getElementById('pbbtargetamountgold').value = r[queueId].target_Gold;
        document.getElementById('pbbtradeamountfood').value = r[queueId].trade_Food;
        document.getElementById('pbbtradeamountwood').value = r[queueId].trade_Wood;
        document.getElementById('pbbtradeamountstone').value = r[queueId].trade_Stone;
        document.getElementById('pbbtradeamountiron').value = r[queueId].trade_Ore;
        document.getElementById('pbbtradeamountaetherstone').value = r[queueId].trade_Astone;
        document.getElementById('pbbtradeamountgold').value = r[queueId].trade_Gold;
        document.getElementById('Cancel').addEventListener('click', function () {t.showTradeRoutes();}, false);
        document.getElementById('Save').addEventListener('click', function () {
            r[queueId].route_state = document.getElementById('TradeStatus')
                .checked;
            r[queueId].TroopType = document.getElementById('pbbTransportTroop')
                .value;
            r[queueId].ship_Food = (document.getElementById('pbbshipfood')
                .checked);
            r[queueId].ship_Wood = (document.getElementById('pbbshipwood')
                .checked);
            r[queueId].ship_Stone = (document.getElementById('pbbshipstone')
                .checked);
            r[queueId].ship_Ore = (document.getElementById('pbbshipiron')
                .checked);
            r[queueId].ship_Astone = (document.getElementById('pbbshipaetherstone')
                .checked);
            r[queueId].ship_Gold = (document.getElementById('pbbshipgold')
                .checked);
            r[queueId].target_Food = parseIntCommas(document.getElementById('pbbtargetamountfood')
                .value);
            r[queueId].target_Wood = parseIntCommas(document.getElementById('pbbtargetamountwood')
                .value);
            r[queueId].target_Stone = parseIntCommas(document.getElementById('pbbtargetamountstone')
                .value);
            r[queueId].target_Ore = parseIntCommas(document.getElementById('pbbtargetamountiron')
                .value);
            r[queueId].target_Astone = parseIntCommas(document.getElementById('pbbtargetamountaetherstone')
                .value);
            r[queueId].target_Gold = parseIntCommas(document.getElementById('pbbtargetamountgold')
                .value);
            r[queueId].trade_Food = parseIntCommas(document.getElementById('pbbtradeamountfood')
                .value);
            r[queueId].trade_Wood = parseIntCommas(document.getElementById('pbbtradeamountwood')
                .value);
            r[queueId].trade_Stone = parseIntCommas(document.getElementById('pbbtradeamountstone')
                .value);
            r[queueId].trade_Ore = parseIntCommas(document.getElementById('pbbtradeamountiron')
                .value);
            r[queueId].trade_Astone = parseIntCommas(document.getElementById('pbbtradeamountaetherstone')
                .value);
            r[queueId].trade_Gold = parseIntCommas(document.getElementById('pbbtradeamountgold')
                .value);
            t.showTradeRoutes();
        }, false);
    },
    saveTradeRoutes: function () {
        var t = Tabs.transport;
        var serverID = getServerId();
        GM_setValue('tradeRoutes_' + serverID, JSON2.stringify(t.tradeRoutes));
    },
    readTradeRoutes: function () {
        var t = Tabs.transport;
        var serverID = getServerId();
        s = GM_getValue('tradeRoutes_' + serverID);
        if (s != null) {
            route = JSON2.parse(s);
            for (k in route)
            t.tradeRoutes[k] = route[k];
        }
        try {
            t.checkcitymoved();
        } catch (e) {
            //Do nothing
        }
    },
    checkcitymoved: function () {
        var t = Tabs.transport;
        for (var i = 0; i < t.tradeRoutes.length; i++) {
            if (typeof t.tradeRoutes[i].target_city == 'undefined' || parseIntNan(t.tradeRoutes[i].target_city) == 0 || Cities.byID[t.tradeRoutes[i].target_city] == 'undefined') continue;
            if (t.tradeRoutes[i].target_x != Cities.byID[t.tradeRoutes[i].target_city].x) t.tradeRoutes[i].target_x = Cities.byID[t.tradeRoutes[i].target_city].x;
            if (t.tradeRoutes[i].target_y != Cities.byID[t.tradeRoutes[i].target_city].y) t.tradeRoutes[i].target_y = Cities.byID[t.tradeRoutes[i].target_city].y;
        }
    },
    saveTraderState: function () {
        var t = Tabs.transport;
        var serverID = getServerId();
        GM_setValue('traderState_' + serverID, JSON2.stringify(t.traderState));
    },
    readTraderState: function () {
        var t = Tabs.transport;
        var serverID = getServerId();
        s = GM_getValue('traderState_' + serverID);
        if (s != null) {
            state = JSON2.parse(s);
            for (k in state)
            t.traderState[k] = state[k];
        }
    },
    toggleTraderState: function (obj) {
        var t = Tabs.transport;
        if (t.traderState.running == true) {
            t.traderState.running = false;
            if (document.getElementById('pbTraderState')) {document.getElementById('pbTraderState').value = "Transport = OFF";document.getElementById('pbTraderState').setAttribute("class", "buttonDash_OFF");}
            if (document.getElementById('TransportToggle')) {document.getElementById('TransportToggle').value = "Transport = OFF";document.getElementById('TransportToggle').setAttribute("class", "buttonDash_OFF");}
            ClearMarchQueue("Transport");
        } else {
            t.traderState.running = true;
            if (document.getElementById('pbTraderState')) {document.getElementById('pbTraderState').value = "Transport = ON";document.getElementById('pbTraderState').setAttribute("class", "buttonDash_ON");}
            if (document.getElementById('TransportToggle')) {document.getElementById('TransportToggle').value = "Transport = ON";document.getElementById('TransportToggle').setAttribute("class", "buttonDash_ON");}
        }
    },   
    doMarch: function(cityID,c){
        var t = Tabs.transport;
        for (var i=0;i<t.tradeRoutes.length;i++) if (parseInt(t.tradeRoutes[i]["city"]) == parseInt(cityID)) t.doTrades(i);
    },   
  	doTrades: function(count){
		var t = Tabs.transport;
	   	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	    params.gold =0;
	    params.r1 =0;
	    params.r2 =0;
	    params.r3 =0;
	    params.r4 =0 ;
	    params.r5 =0 ;
	    params.kid = 0;
	    
	    var carry_amount= 0;
	    var wagons_needed=0;
	    var citymax = 0;
	    var city = t.tradeRoutes[count]["city"];
	    var cityID = 'city' + city;
	    
	    var xcoord = t.tradeRoutes[count]["target_x"];
	    var ycoord = t.tradeRoutes[count]["target_y"];
	    var trade_Food = t.tradeRoutes[count]["trade_Food"];
	    var trade_Wood = t.tradeRoutes[count]["trade_Wood"];
	    var trade_Stone = t.tradeRoutes[count]["trade_Stone"];
	    var trade_Ore = t.tradeRoutes[count]["trade_Ore"];
	    var trade_Astone = t.tradeRoutes[count]["trade_Astone"];
	    var trade_Gold = t.tradeRoutes[count]["trade_Gold"];
	    var target_Food = t.tradeRoutes[count]["target_Food"];
	    var target_Wood = t.tradeRoutes[count]["target_Wood"];
	    var target_Stone = t.tradeRoutes[count]["target_Stone"];
	    var target_Ore = t.tradeRoutes[count]["target_Ore"];
	    var target_Astone = t.tradeRoutes[count]["target_Astone"];
	    var target_Gold = t.tradeRoutes[count]["target_Gold"];
	    var ship_Food = t.tradeRoutes[count]["ship_Food"];
	    var ship_Wood = t.tradeRoutes[count]["ship_Wood"];
	    var ship_Stone = t.tradeRoutes[count]["ship_Stone"];
	    var ship_Ore = t.tradeRoutes[count]["ship_Ore"];
	    var ship_Astone = t.tradeRoutes[count]["ship_Astone"];
	    var ship_Gold = t.tradeRoutes[count]["ship_Gold"];
	    var citymax_Food = parseIntNan(Seed.resources[cityID]['rec1'][0] / 3600);
	    var citymax_Wood = parseIntNan(Seed.resources[cityID]['rec2'][0] / 3600);
	    var citymax_Stone = parseIntNan(Seed.resources[cityID]['rec3'][0] / 3600);
	    var citymax_Ore = parseIntNan(Seed.resources[cityID]['rec4'][0] / 3600);
	    var citymax_Astone = parseIntNan(Seed.resources[cityID]['rec5'][0]);
	    var citymax_Gold = parseIntNan(Seed.citystats[cityID]['gold']);
	    var carry_Food = parseIntNan(citymax_Food - target_Food);
	    var carry_Wood = parseIntNan(citymax_Wood - target_Wood);
	    var carry_Stone = parseIntNan(citymax_Stone - target_Stone);
	    var carry_Ore = parseIntNan(citymax_Ore - target_Ore);
	    var carry_Astone = parseIntNan(citymax_Astone - target_Astone);
	    var carry_Gold = 0;
	    if (carry_Food < 0 || ship_Food == false) carry_Food = 0;
	    if (carry_Wood < 0 || ship_Wood == false) carry_Wood = 0;
	    if (carry_Stone < 0 || ship_Stone == false) carry_Stone = 0;
	    if (carry_Ore < 0 || ship_Ore == false) carry_Ore = 0;
	    if (carry_Astone < 0 || ship_Astone == false) carry_Astone = 0;
	    if (trade_Food > 0 && (carry_Food > trade_Food)) carry_Food = parseIntNan(trade_Food);
	    if (trade_Wood > 0 && (carry_Wood > trade_Wood)) carry_Wood = parseIntNan(trade_Wood);
	    if (trade_Stone > 0 && (carry_Stone > trade_Stone)) carry_Stone = parseIntNan(trade_Stone);
	    if (trade_Ore > 0 && (carry_Ore > trade_Ore)) carry_Ore = parseIntNan(trade_Ore);
	    if (trade_Astone > 0 && (carry_Astone > trade_Astone)) carry_Astone = parseIntNan(trade_Astone);
	    carry_Astone *= 5; //Multiply by 5 to account for 5 times less carrying capacity
	  
	  	if (t.tradeRoutes[count]['TroopType'] == undefined) var wagons = parseInt(Seed.units[cityID]['unt'+ 9]);
	  	 else var wagons =  parseInt(Seed.units[cityID][t.tradeRoutes[count]['TroopType']]);
      
     	var rallypointlevel = t.getRallypoint(cityID);
     	var max = rallypointlevel * 10000;
        var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
		if (Seed.cityData.city[t.tcp.city.id].isPrestigeCity) {
    		switch(parseInt(Seed.cityData.city[t.tcp.city.id].prestigeInfo.prestigeLevel)){
    			case 1: max = Math.floor(max * 1.50);break;
    			case 2: max = Math.floor(max * 1.60);break;
    			case 3: max = Math.floor(max * 1.65);break;
          case 4: max = Math.round(max * 1.70);break;
case 5: max = Math.round(max * 1.75);break;
case 6: max = Math.round(max * 1.80);break;
			}
		}
    	max+=Math.floor(max * (TR / 100));
           
        if (wagons > max) wagons = max;
      	if (t.tradeRoutes[count]['TroopType'] == undefined) var unit = 'unt9';
     	 else var unit = t.tradeRoutes[count]['TroopType'];
      	var Troops = parseInt(Seed.units[cityID][unit]);
      	if(parseInt(Troops)>parseInt(wagons)) Troops = wagons;
      	//var featherweight = parseInt(Seed.tech.tch10);
        //var Load = parseInt(unsafeWindow.unitstats[unit]['5'])
      	var maxloadperwagon = getMaxLoad(unit.substr(3),1); //(featherweight * ((Load/100)*10)) + Load;
      	var maxload = getMaxLoad(unit.substr(3),Troops);
        if(wagons <= 0) return;
        for (var t=0; t< Seed.cities.length;t++) if ( parseInt(Seed.cities[t][0]) == city) var cityname = Seed.cities[t][1];                        
        
		var shift_Food = parseIntNan(maxload / 9); //Total of 9 portions
		var shift_Wood = parseIntNan(maxload / 9);
		var shift_Stone = parseIntNan(maxload / 9);
		var shift_Ore = parseIntNan(maxload / 9);
		var shift_Astone = parseIntNan(maxload / 9 * 5); //Aetherstone takes 5 of 9 portions    
		if ((maxload - carry_Food - carry_Wood - carry_Stone - carry_Ore - carry_Astone) < 0){
			var shift_num=0;
			var shift_spare=0;

			// Check: See if load/4 is to big for some resources...
			if (carry_Food < shift_Food) {
		    	shift_spare += (shift_Food - carry_Food);
		    	shift_Food = carry_Food;
			}
			if (carry_Wood < shift_Wood) {
			    shift_spare += (shift_Wood - carry_Wood);
			    shift_Wood = carry_Wood;
			}
			if (carry_Stone < shift_Stone) {
			    shift_spare += (shift_Stone - carry_Stone);
			    shift_Stone = carry_Stone;
			}
			if (carry_Ore < shift_Ore) {
			    shift_spare += (shift_Ore - carry_Ore);
			    shift_Ore = carry_Ore;
			}
			if (carry_Astone < shift_Astone) {
			    shift_spare += (shift_Astone - carry_Astone);
			    shift_Astone = carry_Astone;
			}                        
             
          	while (shift_spare >1) {
                if (carry_Food < (shift_Food + shift_spare)){
                    shift_spare = shift_spare - carry_Food;;
                    shift_Food = carry_Food;
                }
                else{
                  shift_Food = (shift_Food + shift_spare);
                  shift_spare = shift_spare- shift_spare;
                }
                if (carry_Wood < (shift_Wood + shift_spare)){
                    shift_spare = shift_spare - carry_Wood;;
                    shift_Wood = carry_Wood;
                } else {
                    shift_Wood = shift_Wood + shift_spare;
                    shift_spare = shift_spare - shift_spare;
                }
                if (carry_Stone < (shift_Stone + shift_spare)){
                    shift_spare = shift_spare - carry_Stone;
                    shift_Stone = carry_Stone;
                } else {
                    shift_Stone = shift_Stone + shift_spare;
                    shift_spare = shift_spare - shift_spare;
                }
                if (carry_Ore < (shift_Ore + shift_spare)) {
                    shift_spare = shift_spare - carry_Ore;
                    shift_Ore = carry_Ore;
                } else {
                    shift_Ore = shift_Ore + shift_spare;
                    shift_spare = shift_spare - shift_spare;
                }
                if (carry_Astone < (shift_Astone + shift_spare)) {
                    shift_spare = shift_spare - carry_Astone;
                    shift_Astone = carry_Astone;
                } else {
                    shift_Astone = shift_Astone + shift_spare;
                    shift_spare = shift_spare - shift_spare;
                }
            }
            carry_Food = shift_Food;
            carry_Wood = shift_Wood;
            carry_Stone = shift_Stone;
            carry_Ore = shift_Ore;
            carry_Astone = shift_Astone;
        }
        if (maxload > (carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone) && ship_Gold == true) {
            if ((maxload - (carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone)) > (citymax_Gold - target_Gold)) {
                carry_Gold = (citymax_Gold - target_Gold);
                if (carry_Gold < 0) carry_Gold = 0;
            } else carry_Gold = (maxload - (carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone));
            if (trade_Gold > 0 && (carry_Gold > trade_Gold)) carry_Gold = parseInt(trade_Gold);
        }
        wagons_needed = ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) / maxloadperwagon);
        wagons_needed = wagons_needed.toFixed(0);
        if (wagons_needed < ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) / maxloadperwagon)) wagons_needed++;
        if (wagons_needed < Options.minwagons) {
            if (DEBUG_TRACE) logit('Small transport skipped');
            return;
        }   
        for (var i=1;i<=16;i++) params['u'+i] = 0;     
        switch (unit){
		      case 'unt1': params.u1 = wagons_needed;break;
		      case 'unt2': params.u2 = wagons_needed;break;
		      case 'unt3': params.u3 = wagons_needed;break;
		      case 'unt4': params.u4 = wagons_needed;break;
		      case 'unt5': params.u5 = wagons_needed;break;
		      case 'unt6': params.u6 = wagons_needed;break;
		      case 'unt7': params.u7 = wagons_needed;break;
		      case 'unt8': params.u8 = wagons_needed;break;
		      case 'unt9': params.u9 = wagons_needed;break;
		      case 'unt10': params.u10 = wagons_needed;break;
		      case 'unt11': params.u11 = wagons_needed;break;
		      case 'unt12': params.u12 = wagons_needed;break;
		}
        
        if ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) > 0) {
        	for (i=1;i<=Seed.cities.length;i++) if (Seed.cities[i-1][0] == city) cityNumber = i;
        	var astone = parseInt(carry_Astone/5);
        	var now = unixTime();
        	Options.lastCityTransport[cityNumber] = now;
        	MarchQueue[cityNumber].unshift({
				what: 			"Transport",
				city: 			city,
				action: 		1,
				targetX: 		xcoord,
				targetY: 		ycoord,
				1: 				params.u1,
				2: 				params.u2,
				3: 				params.u3,
				4: 				params.u4,
				5: 				params.u5,
				6: 				params.u6,
				7: 				params.u7,
				8: 				params.u8,
				9: 				params.u9,
				10: 			params.u10,
				11: 			params.u11,
				12: 			params.u12,
				13: 			params.u13,
				14: 			params.u14,
				15: 			params.u15,
				r1: 			carry_Food,
				r2: 			carry_Wood,
				r3: 			carry_Stone,
				r4: 			carry_Ore,
				r5: 			astone,
				gold: 			carry_Gold,
	        });
        }
    },
    
    ManualTransport: function(){
	    var t = Tabs.transport;
	    if (document.getElementById ('ptcityX').value == "" || document.getElementById ('ptcityY').value == "") return;
	    if ( t.TroopsNeeded > t.Troops) return;
	    
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	    var unitType = document.getElementById('TransportTroop').value;
	    var LoadUnit = (parseInt(Seed.tech.tch10) * ((parseInt(unsafeWindow.unitstats[unitType]['5'])/100)*10)) + parseInt(unsafeWindow.unitstats[unitType]['5']);
	    var MaxLoad =  parseInt(Seed.units['city' + t.tcp.city.id][unitType]) * LoadUnit;
	    document.getElementById ('errorSpace').innerHTML = '';
	          
	    params.kid = 0;
	    params.cid=  t.tcp.city.id;
	    params.type = "1";
	    params.xcoord = parseInt(document.getElementById ('ptcityX').value);
	    params.ycoord = parseInt(document.getElementById ('ptcityY').value);
	    params.r1 = parseInt(document.getElementById ('pbtradeamountFood').value);
	    params.r2 = parseInt(document.getElementById ('pbtradeamountWood').value);
	    params.r3 = parseInt(document.getElementById ('pbtradeamountStone').value);
	    params.r4 = parseInt(document.getElementById ('pbtradeamountOre').value);
	    params.r5 = parseInt(document.getElementById ('pbtradeamountAstone').value);
	    params.gold = parseInt(document.getElementById ('pbtradeamountGold').value);
	        
	    switch (unitType){
	      case 'unt1': params.u1 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt2': params.u2 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt3': params.u3 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt4': params.u4 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt5': params.u5 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt6': params.u6 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt7': params.u7 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt8': params.u8 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt9': params.u9 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt10': params.u10 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt11': params.u11 = parseInt(document.getElementById ('TroopsToSend').value);break;
	      case 'unt12': params.u12 = parseInt(document.getElementById ('TroopsToSend').value);break;
	    }
	    if ((params.r1 + params.r2 + params.r3 + params.r4 + params.r5 + params.gold) > 0) {
	                 
	        var profiler = new unsafeWindow.cm.Profiler("ResponseTime", "march.php");
	        new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
	                  method: "post",
	                  parameters: params,
	                  loading: true,
	                  onSuccess: function (transport) {
						  profiler.stop();
	                  var rslt = eval("(" + transport.responseText + ")");
	                  if (rslt.ok) {                  
	                          var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                          var ut = unixTime();
	                          var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	                          for(i = 0; i <= unitsarr.length; i++){
	                              if(params["u"+i]){
	                              unitsarr[i] = params["u"+i];
	                              }
	                          }
	                          var resources=new Array();
	                          resources[0] = params.gold;
	                          for(i=1; i<=5; i++){
	                              resources[i] = params["r"+i];
	                          }
	                          var currentcityid = t.tcp.city.id;
	                          unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                          if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
	                          document.getElementById ('errorSpace').innerHTML = 'Send: ' + addCommas(params.r1+params.r2+params.r3+params.r4+params.r5+params.gold) + ' Resources with ' + addCommas(parseInt(document.getElementById ('TroopsToSend').value)) + ' ' + unsafeWindow.unitcost[unitType][0];
	                          document.getElementById ('pbtradeamountFood').value = 0;
	                          document.getElementById ('pbtradeamountWood').value = 0;
	                          document.getElementById ('pbtradeamountStone').value = 0;
	                          document.getElementById ('pbtradeamountOre').value = 0;
	                          document.getElementById ('pbtradeamountAstone').value = 0;
	                          document.getElementById ('pbtradeamountGold').value = 0;
	                          document.getElementById ('TroopsToSend').value = 0;
	                  } else {
						    if (rslt.user_action == "backOffWaitTime") {
							logit('backoffwaittime '+rslt.wait_time);
	                        var wait = 1;
	                        if(rslt.wait_time)
	                        wait = rslt.wait_time;
	                        setTimeout (function(){t.ManualTransport();}, wait*1000);
	                        document.getElementById ('errorSpace').innerHTML = '<HR><FONT COLOR=red>'+translate("Error:")+' ' + 'kabam making us wait for '+wait+' seconds then retry march' +'</font>';
	                        return;
						  };
	                          var errorcode =  'err_' + rslt.error_code;
	                          if (rslt.msg == undefined)document.getElementById ('errorSpace').innerHTML = '<HR><FONT COLOR=red>'+translate("Error:")+' ' + unsafeWindow.g_js_strings.errorcode[errorcode] +'</font>';
	                          else document.getElementById ('errorSpace').innerHTML = '<HR><FONT COLOR=red>'+translate("Error:")+' ' + rslt.msg +'</font>';
	                  }
	                  },
	                  onFailure: function () {profiler.stop();}
	        });
	    }
    },
    show: function () {
        var t = Tabs.transport;
        if (t.traderState.running) document.getElementById('pbTraderState').value = "Transport = ON";
        	else document.getElementById('pbTraderState').value = "Transport = OFF";
        clearTimeout(t.timer);
        t.updateTroops();
        t.updateResources();
        t.timer = setTimeout(t.show, 1000);
    },
    hide: function () {
        var t = Tabs.transport;
        clearTimeout(t.timer);
    },
    onUnload: function () {
        var t = Tabs.transport;
        if (!ResetAll) t.saveTradeRoutes();
        if (!ResetAll) t.saveTraderState();
    },
}


/*********************************  Raid Tab ***********************************/

 Tabs.Raid = {
  tabDisabled : false,
  tabOrder : 110,
  myDiv : null,
  rallypointlevel:null,
  knt:{},
  Troops:{},
  city:0,
  raidtimer:null,
  rslt:{},
  save:{},
  stopping:false,
  resuming:false,
  deleting:false,
  stopprogress:0,
  stopcount:0,
  activecount:0,
  count:0,
  
  init : function (div){
    var t = Tabs.Raid;
    t.myDiv = div;
    t.raidtimer = setTimeout(t.checkRaids, 30000);

    var m = '<DIV class=pbStat>RAID FUNCTIONS</div><TABLE width=100% height=0% class=pbTab><TR align="center">';
        m += '<TD><INPUT id=pbRaidStart type=submit value="Auto Reset = '+ (Options.RaidRunning?'ON':'OFF') +'" ></td>';
        m += '<TD><INPUT id=pbsendraidreport type=checkbox '+ (Options.foodreport?'CHECKED':'') +'\> Send raid report every ';
        m += '<INPUT id=pbsendreportint value='+ Options.MsgInterval +' type=text size=3 \> hours </td>';
        m += '</tr></table></div>';
        m += '<DIV class=pbStat>ACTIVE RAIDS</div><TABLE width=100% height=0% class=pbTab><TR align="center">';
        m += '<TD><DIV style="margin-bottom:10px;"><span id=ptRaidCity></span></div></td></tr>';
        m+='<TR><TD><DIV style="margin-bottom:10px;"><span id=ptRaidTimer></span></div></td></tr></table>';
        m += '<DIV id=PaintRaids></div>';
        m += '<DIV class=pbStat>SAVED RAIDS</div><TABLE width=100% height=0% class=pbTab><TR align="center">';
        m += '<DIV id=SavedRaids></div>';
    t.myDiv.innerHTML = m;
    
    t.from = new CdispCityPicker ('ptRaidpicker', document.getElementById('ptRaidCity'), true, t.clickCitySelect, 0);
    document.getElementById('pbRaidStart').addEventListener('click', t.toggleRaidState, false);
    document.getElementById('pbsendraidreport').addEventListener('change', function(){
        Options.foodreport = document.getElementById('pbsendraidreport').checked;
        saveOptions();
    }, false);
    document.getElementById('pbsendreportint').addEventListener('change', function(){
        Options.MsgInterval = parseInt(document.getElementById('pbsendreportint').value);
        saveOptions();
    }, false);
    
    var serverID = getServerId();
    t.save = GM_getValue ('SavedRaids_'+serverID);
    if (t.save != undefined) t.save = JSON2.parse (t.save);
    
  },
 
  paint : function ()    {
      var t = Tabs.Raid;
      var botMarchStat = {0:'Inactive',
                          1:'Raiding',
                          2:'Returning',
                          3:'Stopped',
                          4:'Resting',
                          5:'Unknown',
                          7:'Situation Changed',
                          8:'Returning',
                          9:'Aborting'};
      var botStat = {0:'Undefined',
                          1:'Marching',
                          2:'Returning',
                          3:'Stopped',
                          4:'Insufficient Troops',
                          5:'Max Raids Exceeded',
                          7:'Timed out',
                          8:'Resting'};
      var o = '';
      if (t.rslt.settings != undefined) o+= '<FONT size=2px><B>Raid Timer: '+ timestr( 86400 - ( unixTime() - t.rslt.settings.lastUpdated )) +'</b></font>';
      document.getElementById('ptRaidTimer').innerHTML = o;
      
      var z ='<TABLE class=pbTab><TR><TD width=60px align=center><A onclick="pbStopAll('+t.cityId+')">STOP</a></td><TD width=70px>Time</td><TD width=85px>Coords</td><TD width=50px>Level</td><TD width=50px></td><TD width=50px><A onclick="pbDeleteAll()">DELETE</a></td></TR>';
      if (t.rslt['queue'] != ""){
          for (y in t.rslt['queue']) {
              if (t.rslt['queue'][y]['botMarches'] != undefined) {
                  for (k in Seed.queue_atkp['city' + t.cityId]){
                      if (Seed.queue_atkp['city' + t.cityId][k]['marchId'] == t.rslt['queue'][y]['botMarches']['marchId']) {
                          botMarchStatus = Seed.queue_atkp['city' + t.cityId][k]['botMarchStatus'];
                          MarchStatus = Seed.queue_atkp['city' + t.cityId][k]['marchStatus'];
                          restPeriod = (Seed.queue_atkp['city' + t.cityId][k]['restPeriod']/60);
                          destinationUnixTime = Seed.queue_atkp['city' + t.cityId][k]['destinationUnixTime'];
                          returnUnixTime = Seed.queue_atkp['city' + t.cityId][k]['returnUnixTime']
                          now = unixTime();
                          //z+='<TR><TD>('+ botMarchStatus +'/'+ MarchStatus +')</td>';
                          z+='<TR>';
                          //if (destinationUnixTime > now && botMarchStatus !=3) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg></td>';
                          if (MarchStatus ==1) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg></td>';
                          //if ((destinationUnixTime - now) <= 0 && botMarchStatus !=3 && returnUnixTime > now) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/returning.jpg></td>';
                          if (MarchStatus ==8 && (destinationUnixTime - now) <= 0 && botMarchStatus !=3 && returnUnixTime > now) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/returning.jpg></td>';
                          if (MarchStatus == 3) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/autoAttack/raid_stopped_desat.png></td>';
                          //if (returnUnixTime < now  && botMarchStatus !=3) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/autoAttack/raid_resting.png></td>';
                          if (MarchStatus == 4 || (returnUnixTime < now  && botMarchStatus !=3)) z+='<TD align=center><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/autoAttack/raid_resting.png></td>';
                          
                          if (destinationUnixTime >= now) z+='<TD>'+ timestr(Seed.queue_atkp['city' + t.cityId][k]['destinationUnixTime'] - unixTime())+'</td>';
                          if (destinationUnixTime <= now) {
                              if ((destinationUnixTime - now) <= 0 && returnUnixTime > now) z+='<TD>'+ timestr(returnUnixTime - now)+'</td>';
                              if (returnUnixTime <= now) z+='<TD>'+ timestr(now - returnUnixTime)+'</td>';
                          }
                      }
                  }
                  z+='<TD>('+ t.rslt['queue'][y]['botMarches']['toXCoord'] +','+ t.rslt['queue'][y]['botMarches']['toYCoord']+')</td>';
                  z+='<TD align=center>'+ t.rslt['queue'][y]['botMarches']['toTileLevel'] +'</td>';
                  if (botMarchStatus == 3) z+='<TD><A onclick="pbEditRaid('+ y +')">Edit</a></td>';
                      else z+='<TD><FONT COLOR= "CCCCCC">Edit</font></td>';
                  if (botMarchStatus == 3) z+='<TD align=center><A onclick="pbDeleteRaid('+ t.rslt['queue'][y]['botMarches']['marchId']+')">Delete</a></td>';
                  else z+='<TD align=center><FONT COLOR= "CCCCCC">Delete</font></td>';
                  //z +='<TD width=25px></td><TD>Status: '+ botMarchStat[botMarchStatus]+'</td>';
                  z +='<TD width=25px></td><TD>Rest Time: '+ timestr(restPeriod) +'</td>';
                  z+='</tr>';
              }
          }
      }
      z+='</table>';
      if (t.rslt['queue'] == "") z ='<TABLE class=pbTab><TR><TD>No Raids in city!</td></TR>';
      document.getElementById('PaintRaids').innerHTML = z;
      
      var check = true;
          if (t.save != ""){
              var a ='<TABLE class=pbTab><TR><TD width=60px></td><TD width=70px></td><TD width=85px>Coords</td><TD width=50px>Level</td><TD width=50px></td><TD width=50px></td></tr>';
              for (y in t.save){
                  if (t.save[y] != undefined && t.cityId == t.save[y]['cityId']){
                      a +='<TR><TD align=center><A onclick="pbDeleteSavedRaid('+ t.save[y]['marchId'] +')">X</a></td>';
                      a +='<TD></td><TD><FONT COLOR= "CC0000">('+t.save[y]['toXCoord']+','+t.save[y]['toYCoord']+')</font></td>';
                      a +='<TD align=center>'+t.save[y]['toTileLevel']+'</td>';
                      a +='<TD><A onclick="pbEditSavedRaid('+ y +')">Edit</a></td>';
                      a +='<TD align=center><A onclick="pbAddRaid('+ t.save[y]['marchId']+')">Add</a></td></tr>';
                      check = false;
                  }    
              }
              m+='</table>';
          }
          
      if (check) a ='<TABLE class=pbTab><TR><TD>No Saved Raids in city!</td></TR>';
      
      document.getElementById('SavedRaids').innerHTML = a;      
      
      unsafeWindow.pbDeleteRaid = t.DeleteRaid;
      unsafeWindow.pbEditRaid = t.EditRaid;
      unsafeWindow.pbAddRaid = t.AddRaid;
      unsafeWindow.pbDeleteSavedRaid = t.DeleteSavedRaid;
      unsafeWindow.pbEditSavedRaid = t.EditSavedRaid;
      unsafeWindow.pbStopAll = t.StopCityRaids;
      unsafeWindow.pbDeleteAll = t.DeleteCityRaids;
  },
  
  DeleteSavedRaid : function (Id){
          var t = Tabs.Raid;
          for (yy=0;yy<t.save.length;yy++){
              if (t.save[yy]['marchId'] == Id){
                    t.save.splice (yy,1);
              }    
          }
          var serverID = getServerId();
          setTimeout (function (){GM_setValue ('SavedRaids_'+serverID, JSON2.stringify(t.save));}, 0);
          t.paint();
    },
  
  EditSavedRaid : function (y){
      var t = Tabs.Raid;
      var pop = new pbPopup ('pbEditRaid', 0,0, 750,350, true);
      if (t.popFirst){
        pop.centerMe (mainPop.getMainDiv());  
        t.popFirst = false;
      }
      pop.getTopDiv().innerHTML = '<CENTER><B>Edit Saved Raid</b></center>';
      cityId =  t.save[y]['cityId'];
      
          var m = '<BR><TABLE id=pbRaidAdd height=0% class=pbTab><TR align="center">';
          m+='<TR></tr><TR><TD width=25px>X= <INPUT id=toXCoord type=text size=3 maxlength=3 value='+t.save[y]['toXCoord']+'></td>';
          m+='<TD width=10px></td><TD widht=25px>Y= <INPUT id=toYCoord type=text size=3 maxlength=3 value='+ t.save[y]['toYCoord'] +'></td>';
          m+='<TD width=25px></td><TD>Round Trip: '+ timestr((t.save[y]['returnUnixTime'] - t.save[y]['destinationUnixTime'])*2)+ '</td></tr></table>';

          m += '<BR><TABLE id=pbRaidAdd width=100% height=0% class=pbTab><TR align="center">';
          m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_1_50.jpg?6545?6545"></td>';
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt1']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_2_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt2']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_3_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt3']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_4_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt4']) +'</td></tr>'
          m += '<TR><TD><INPUT id=Unit1 type=text size=6 maxlength=6 value="'+ t.save[y]['unit1Count']+'"></td>';
          m += '<TD><INPUT id=Unit2 type=text size=6 maxlength=6 value="'+ t.save[y]['unit2Count']+'"></td>';
          m += '<TD><INPUT id=Unit3 type=text size=6 maxlength=6 value="'+ t.save[y]['unit3Count']+'"></td>';
          m += '<TD><INPUT id=Unit4 type=text size=6 maxlength=6 value="'+ t.save[y]['unit4Count']+'"></td></tr>';
          
          m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_5_50.jpg?6545?6545"></td>';
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt5']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_6_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt6']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_7_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt7']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_8_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt8']) +'</td></tr>'
          m += '<TR><TD><INPUT id=Unit5 type=text size=6 maxlength=6 value="'+ t.save[y]['unit5Count']+'"></td>';
          m += '<TD><INPUT id=Unit6 type=text size=6 maxlength=6 value="'+ t.save[y]['unit6Count']+'"></td>';
          m += '<TD><INPUT id=Unit7 type=text size=6 maxlength=6 value="'+ t.save[y]['unit7Count']+'"></td>';
          m += '<TD><INPUT id=Unit8 type=text size=6 maxlength=6 value="'+ t.save[y]['unit8Count']+'"></td></tr>';
          
          m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_9_50.jpg?6545?6545"></td>';
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt9']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_10_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt10']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_11_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt11']) +'</td>'
          m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_12_50.jpg?6545?6545"></td>'
          m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt12']) +'</td></tr>'
          m += '<TR><TD><INPUT id=Unit9 type=text size=6 maxlength=6 value="'+ t.save[y]['unit9Count']+'"></td>';
          m += '<TD><INPUT id=Unit10 type=text size=6 maxlength=6 value="'+ t.save[y]['unit10Count']+'"></td>';
          m += '<TD><INPUT id=Unit11 type=text size=6 maxlength=6 value="'+ t.save[y]['unit11Count']+'"></td>';
          m += '<TD><INPUT id=Unit12 type=text size=6 maxlength=6 value="'+ t.save[y]['unit12Count']+'"></td></tr></table>';
          
          m += '<BR><CENTER><SELECT id=AddKnights type=list></select></center>';
          m+= '<BR><CENTER>'+ strButton20('Save', 'id=pbSaveRaid') +'</center>';
            
      pop.getMainDiv().innerHTML = m;
      
      t.getKnights(cityId);
      
      document.getElementById ('AddKnights').value =  t.save[y]['knightId'];
      document.getElementById ('pbSaveRaid').addEventListener ('click', function(){
                  t.save[y]['knightId'] = parseInt(document.getElementById ('AddKnights').value);
                  t.save[y]['toXCoord'] = parseInt(document.getElementById ('toXCoord').value);
                  t.save[y]['toYCoord'] = parseInt(document.getElementById ('toYCoord').value);
                  t.save[y]['unit1Count'] = parseInt(document.getElementById ('Unit1').value);
                  t.save[y]['unit2Count'] = parseInt(document.getElementById ('Unit2').value);
                  t.save[y]['unit3Count'] = parseInt(document.getElementById ('Unit3').value);
                  t.save[y]['unit4Count'] = parseInt(document.getElementById ('Unit4').value);
                  t.save[y]['unit5Count'] = parseInt(document.getElementById ('Unit5').value);
                  t.save[y]['unit6Count'] = parseInt(document.getElementById ('Unit6').value);
                  t.save[y]['unit7Count'] = parseInt(document.getElementById ('Unit7').value);
                  t.save[y]['unit8Count'] = parseInt(document.getElementById ('Unit8').value);
                  t.save[y]['unit9Count'] = parseInt(document.getElementById ('Unit9').value);
                  t.save[y]['unit10Count'] = parseInt(document.getElementById ('Unit10').value);
                  t.save[y]['unit11Count'] = parseInt(document.getElementById ('Unit11').value);
                  t.save[y]['unit12Count'] = parseInt(document.getElementById ('Unit12').value);
                  var serverID = getServerId();
                  setTimeout (function (){GM_setValue ('SavedRaids_'+serverID, JSON2.stringify(t.save));}, 0);
                  pop.show (false);
      }, false);
      
      pop.show (true);      
    },
      
  EditRaid : function (y){
        var t = Tabs.Raid;
        var pop = new pbPopup ('pbEditRaid', 0,0, 750,350, true);
        if (t.popFirst){
          pop.centerMe (mainPop.getMainDiv());  
          t.popFirst = false;
        }
        pop.getTopDiv().innerHTML = '<CENTER><B>Edit Raid</b></center>';
        cityId = t.rslt['queue'][y]['botMarches']['cityId'];
        
            var m = '<BR><TABLE id=pbRaidAdd height=0% class=pbTab><TR align="center">';
            m+='<TR></tr><TR><TD width=25px>X= <INPUT id=toXCoord type=text size=3 maxlength=3 value='+t.rslt['queue'][y]['botMarches']['toXCoord']+'></td>';
            m+='<TD width=10px></td><TD widht=25px>Y= <INPUT id=toYCoord type=text size=3 maxlength=3 value='+ t.rslt['queue'][y]['botMarches']['toYCoord'] +'></td>';
            m+='<TD width=25px></td><TD>Round Trip: '+ timestr((t.rslt['queue'][y]['botMarches']['returnUnixTime'] - t.rslt['queue'][y]['botMarches']['destinationUnixTime'])*2)+ '</td></tr></table>';

            m += '<BR><TABLE id=pbRaidAdd width=100% height=0% class=pbTab><TR align="center">';
            m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_1_50.jpg?6545?6545"></td>';
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt1']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_2_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt2']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_3_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt3']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_4_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt4']) +'</td></tr>'
            m += '<TR><TD><INPUT id=Unit1 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit1Count']+'"></td>';
            m += '<TD><INPUT id=Unit2 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit2Count']+'"></td>';
            m += '<TD><INPUT id=Unit3 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit3Count']+'"></td>';
            m += '<TD><INPUT id=Unit4 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit4Count']+'"></td></tr>';
            
            m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_5_50.jpg?6545?6545"></td>';
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt5']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_6_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt6']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_7_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt7']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_8_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt8']) +'</td></tr>'
            m += '<TR><TD><INPUT id=Unit5 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit5Count']+'"></td>';
            m += '<TD><INPUT id=Unit6 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit6Count']+'"></td>';
            m += '<TD><INPUT id=Unit7 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit7Count']+'"></td>';
            m += '<TD><INPUT id=Unit8 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit8Count']+'"></td></tr>';
            
            m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_9_50.jpg?6545?6545"></td>';
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt9']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_10_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt10']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_11_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt11']) +'</td>'
            m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_12_50.jpg?6545?6545"></td>'
            m += '<TD>'+ addCommas(Seed.units['city'+cityId]['unt12']) +'</td></tr>'
            m += '<TR><TD><INPUT id=Unit9 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit9Count']+'"></td>';
            m += '<TD><INPUT id=Unit10 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit10Count']+'"></td>';
            m += '<TD><INPUT id=Unit11 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit11Count']+'"></td>';
            m += '<TD><INPUT id=Unit12 type=text size=6 maxlength=6 value="'+ t.rslt['queue'][y]['botMarches']['unit12Count']+'"></td></tr></table>';
            
            m += '<BR><CENTER><SELECT id=AddKnights type=list></select></center>';
            m+= '<BR><CENTER>'+ strButton20('Save', 'id=pbRaidSave') +'</center>';
              
        pop.getMainDiv().innerHTML = m;
        
        t.getKnights(cityId);
        
        document.getElementById ('AddKnights').value =  t.rslt['queue'][y]['botMarches']['knightId'];
        document.getElementById ('pbRaidSave').addEventListener ('click', function(){
            var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                              
            params.pf = 0;
            params.ctrl = 'BotManager';
            params.action = 'editMarch';
            params.settings = {};
            params.settings.cityId = t.rslt['queue'][y]['botMarches']['fromCityId'];
            params.queue = {0:{botMarches:{botMarchStatus:1,botState:1},cityMarches:{}}};        
            params.queue[0].cityMarches.knightId = parseInt(document.getElementById ('AddKnights').value);
            params.queue[0].cityMarches.toXCoord =  parseInt(document.getElementById ('toXCoord').value);
            params.queue[0].cityMarches.toYCoord =  parseInt(document.getElementById ('toYCoord').value);
            params.queue[0].cityMarches.unit0Count = 0; //document.getElementById ('Unit0').value;
            params.queue[0].cityMarches.unit1Count =  parseInt(document.getElementById ('Unit1').value);
            params.queue[0].cityMarches.unit2Count = parseInt(document.getElementById ('Unit2').value);
            params.queue[0].cityMarches.unit3Count = parseInt(document.getElementById ('Unit3').value);
            params.queue[0].cityMarches.unit4Count = parseInt(document.getElementById ('Unit4').value);
            params.queue[0].cityMarches.unit5Count = parseInt(document.getElementById ('Unit5').value);
            params.queue[0].cityMarches.unit6Count = parseInt(document.getElementById ('Unit6').value);
            params.queue[0].cityMarches.unit7Count = parseInt(document.getElementById ('Unit7').value);
            params.queue[0].cityMarches.unit8Count = parseInt(document.getElementById ('Unit8').value);
            params.queue[0].cityMarches.unit9Count = parseInt(document.getElementById ('Unit9').value);
            params.queue[0].cityMarches.unit10Count = parseInt(document.getElementById ('Unit10').value);
            params.queue[0].cityMarches.unit11Count = parseInt(document.getElementById ('Unit11').value);
            params.queue[0].cityMarches.unit12Count = parseInt(document.getElementById ('Unit12').value);
            params.queue[0].cityMarches.marchId =  t.rslt['queue'][y]['botMarches']['marchId'];
            
            
             new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                            method: "post",
                           parameters: params,
                           loading: true,
                           onSuccess: function(transport){
                              var rslt = eval("(" + transport.responseText + ")");
                                if (rslt.ok) {
                                        pop.show (false);
                                      unsafeWindow.cityinfo_army();
                                    setTimeout(unsafeWindow.update_seed_ajax, 250);
                                    setTimeout(t.GetRaids, (750),Seed.cities[i][0]);
                                  }
                           },
                   });
            }, false);
        
        pop.show (true);      
  },
  
  DeleteRaid : function (Id){
      var t = Tabs.Raid;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      
      for (y in t.rslt['queue']) {
          if (t.rslt['queue'][y]['botMarches'] != undefined) {
              if (t.rslt['queue'][y]['botMarches']['marchId'] == Id) {
                      marchId = t.rslt['queue'][y]['botMarches']['marchId'];
                      cityId = t.rslt['queue'][y]['botMarches']['cityId'];
                      knightId = t.rslt['queue'][y]['botMarches']['knightId'];
                      toTileLevel = t.rslt['queue'][y]['botMarches']['toTileLevel'];
                      returnUnixTime = t.rslt['queue'][y]['botMarches']['returnUnixTime'];
                      destinationUnixTime = t.rslt['queue'][y]['botMarches']['destinationUnixTime'];
                      toXCoord = t.rslt['queue'][y]['botMarches']['toXCoord'];
                      toYCoord = t.rslt['queue'][y]['botMarches']['toYCoord'];
                      var units = {};
                      for (i=1;i<13;i++) units[i] = t.rslt['queue'][y]['botMarches']['unit'+i+'Count'];
              }
          }
      }    
      
      params.pf = 0;
      params.ctrl = 'BotManager';
      params.action = 'deleteMarch';
      params.marchId = marchId;
      params.settings = {};
      params.settings.cityId = cityId;

      
      
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
               method: "post",
               parameters: params,
               loading: true,
               onSuccess: function(transport){
                  var rslt = eval("(" + transport.responseText + ")");
                    if (rslt.ok) {
                          var serverID = getServerId();
                          t.save = GM_getValue ('SavedRaids_'+serverID);
                          if (t.save == undefined) t.save =new Array();
                      else t.save = JSON2.parse (t.save);
                      
                          t.save.push ({
                              marchId:        marchId,
                              cityId:           cityId,
                              knightId:        knightId,
                              toTileLevel:    toTileLevel,
                              returnUnixTime:    destinationUnixTime,
                              returnUnixTime:    returnUnixTime,
                              toXCoord:        toXCoord,
                              toYCoord:        toYCoord,
                              unit1Count:     units[1],
                              unit2Count:     units[2],
                              unit3Count:     units[3],
                              unit4Count:     units[4],
                              unit5Count:     units[5],
                              unit6Count:     units[6],
                              unit7Count:     units[7],
                              unit8Count:     units[8],
                              unit9Count:     units[9],
                              unit10Count:     units[10],
                              unit11Count:     units[11],
                              unit12Count:     units[12],
                          });
                          var troops = Seed.units["city" + cityId];
                      for (var u = 1; u <= 12; ++u) {
                          var troop_number = parseInt(rslt["unit" + u + "Return"]);
                          if (isNaN(troop_number)) {
                              troop_number = parseInt(Seed.units["city" + cityId]["unt" + u]);
                          } else troop_number = parseInt(rslt["unit" + u + "Return"]) + parseInt(Seed.units["city" + cityId]["unt" + u]);
                          troops["unt" + u] = troop_number;
                      }
                      for (u in Seed.queue_atkp['city' + cityId]){
                          if (Seed.queue_atkp['city' + cityId][u]['marchId'] == marchId){
                            Seed.queue_atkp['city' + cityId][u] = "";
                              unsafeWindow.seed.queue_atkp['city' + cityId] = Seed.queue_atkp['city' + cityId];
                          }
                      }
                      
                      for (u in Seed.knights['city' + cityId]){
                          if (Seed.knights['city' + cityId][u]['knightId'] == knightId){
                              Seed.knights['city' + cityId][u]["knightStatus"] = 1;
                              unsafeWindow.seed.knights['city' + cityId] = Seed.knights['city' + cityId];
                          }
                      }
                                                      
                          GM_setValue ('SavedRaids_'+serverID, JSON2.stringify(t.save));
                          t.save = null;
                      unsafeWindow.cityinfo_army();
                        setTimeout(unsafeWindow.update_seed_ajax, 250);
                        t.GetRaids(cityId);
                      }
               },
       });
},
  
  StopCityRaids : function (cityId){
        var t = Tabs.Raid;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);

        
        params.pf = 0;
        params.ctrl = 'BotManager';
        params.action = 'stopAll';
        params.settings = {};

          params.settings.cityId = cityId;
               
         new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                      method: "post",
                     parameters: params,
                     loading: true,
                     onSuccess: function(transport){
                        var rslt = eval("(" + transport.responseText + ")");
                          if (rslt.ok) {
                                  
                          }
                     },
             });   
    setTimeout(t.GetRaids, (750), cityId);     
    },
  
  StopAllRaids : function (){
          var t = Tabs.Raid;
          if (t.stopping == true || t.resuming == true || t.deleting == true) return;
          if (t.activecount == 0) return;
        t.stopping = true;     
              for (i=0;i<Seed.cities.length;i++){
                  setTimeout(t.DoAllStop, (i*1500),i);
             }
   },
   
   ResumeAllRaids : function (){
           var t = Tabs.Raid;
           if (t.stopping == true || t.resuming == true || t.deleting == true) return;
           if (t.stopcount == 0) return;
           t.resuming = true;
               for (i=0;i<Seed.cities.length;i++){
                   setTimeout(t.DoAllResume, (i*1500),i);
               }
    },
   
   
   DeleteAllRaids : function (){
           var t = Tabs.Raid;
           if (t.stopping == true || t.resuming == true || t.deleting == true) return;
           if (t.stopcount == 0) return;
           t.deleting = true;
           count=0;
           t.count = t.stopcount;
                for (d=0; d< Seed.cities.length;d++) {
                        cityID = 'city' + Seed.cities[d][0];    
                            for (e in Seed.queue_atkp[cityID]){
                                destinationUnixTime = Seed.queue_atkp[cityID][e]['destinationUnixTime'];
                                MarchStatus = Seed.queue_atkp[cityID][e]['marchStatus'];
                                MarchType = Seed.queue_atkp[cityID][e]['marchType'];
                                if (MarchType == 9 && (botMarchStatus == 3 || MarchStatus == 3)) {
                                    count++;
                                    setTimeout(t.DoAllDelete, (count*1250), (Seed.queue_atkp[cityID][e]['marchId']),d,count);
                                }
                            }
                }
    },
    
  
  DoAllStop: function(i) {
    var t = Tabs.Raid;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.pf = 0;
      params.ctrl = 'BotManager';
      params.action = 'stopAll';
      params.settings = {};
      params.settings.cityId = Seed.cities[i][0];
           
                
           new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                        method: "post",
                       parameters: params,
                       loading: true,
                       onSuccess: function(transport){
                          var rslt = eval("(" + transport.responseText + ")");
                            if (rslt.ok) {
                                    t.stopprogress = t.stopprogress + (100/Seed.cities.length);
                                    actionLog('Stopping: '+ Seed.cities[i][1]);
                                    if (t.stopprogress.toFixed(0) == 100) {
                                         t.stopprogress = 0;
                                    }        
                            }
                            else {
                                    if (rslt.msg == "The system is busy, please try again later") setTimeout (t.DoAllStop, (2000),i);
                                    else {
                                         t.stopprogress = t.stopprogress + (100/Seed.cities.length);
                                         actionLog('Stopping: '+ Seed.cities[i][1] + ' - ' + rslt.msg);
                                         if (t.stopprogress.toFixed(0) == 100) {
                                              t.stopprogress = 0;
                                         }
                                     }
                             }
                       },
    });  
  },

  DoAllResume: function(i) {
    var t = Tabs.Raid;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.pf = 0;
      params.ctrl = 'BotManager';
      params.action = 'resumeAll';
      params.settings = {};
    params.settings.cityId = Seed.cities[i][0];
                
                  
           new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                        method: "post",
                       parameters: params,
                       loading: true,
                       onSuccess: function(transport){
                          var rslt = eval("(" + transport.responseText + ")");
                            if (rslt.ok) {
                                    t.stopprogress = t.stopprogress + (100/Seed.cities.length);
                                    actionLog('Resuming: '+ Seed.cities[i][1]);
                                    if (t.stopprogress.toFixed(0) == 100) {
                                         t.stopprogress = 0;
                                    }        
                            }
                            else {
                                    if (rslt.msg == "The system is busy, please try again later") setTimeout (t.DoAllResume, (2000),i);
                                    else {
                                         t.stopprogress = t.stopprogress + (100/Seed.cities.length);
                                         actionLog('Stopping: '+ Seed.cities[i][1]  + ' - ' + rslt.msg);
                                         if (t.stopprogress.toFixed(0) == 100) {
                                              t.stopprogress = 0;
                                         }    
                                     }
                             }
                       },
    });  
  },
  
  DoAllDelete : function (Id,city,count){
        var t = Tabs.Raid;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        
        cityID = 'city'+ Seed.cities[city][0];
        
        for (f in Seed.queue_atkp[cityID]){
            if (Seed.queue_atkp[cityID][f]['marchId'] == Id) {
                    marchId = Seed.queue_atkp[cityID][f]['marchId'];
                    cityId = Seed.queue_atkp[cityID][f]['cityId'];
                    knightId = Seed.queue_atkp[cityID][f]['knightId'];
                    toTileLevel = Seed.queue_atkp[cityID][f]['toTileLevel'];
                    returnUnixTime = Seed.queue_atkp[cityID][f]['returnUnixTime'];
                    destinationUnixTime = Seed.queue_atkp[cityID][f]['destinationUnixTime'];
                    toXCoord = Seed.queue_atkp[cityID][f]['toXCoord'];
                    toYCoord = Seed.queue_atkp[cityID][f]['toYCoord'];
                    var units = {};
                    for (i=1;i<13;i++) units[i] = Seed.queue_atkp[cityID][f]['unit'+i+'Count'];
            }
        }
        
        params.pf = 0;
        params.ctrl = 'BotManager';
        params.action = 'deleteMarch';
        params.marchId = marchId;
        params.settings = {};
        params.settings.cityId = cityId;
       
      new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                 method: "post",
                 parameters: params,
                 loading: true,
                 onSuccess: function(transport){
                    var rslt = eval("(" + transport.responseText + ")");
                      if (rslt != "") {
                            var serverID = getServerId();
                            t.save = GM_getValue ('SavedRaids_'+serverID, "[]");
                            if (t.save != undefined) t.save = JSON2.parse (t.save);
                            if (t.save == undefined) t.save =new Array();
  
                            t.save.push ({
                                marchId:        marchId,
                                cityId:           cityId,
                                knightId:        knightId,
                                toTileLevel:    toTileLevel,
                                returnUnixTime:    destinationUnixTime,
                                returnUnixTime:    returnUnixTime,
                                toXCoord:        toXCoord,
                                toYCoord:        toYCoord,
                                unit1Count:     units[1],
                                unit2Count:     units[2],
                                unit3Count:     units[3],
                                unit4Count:     units[4],
                                unit5Count:     units[5],
                                unit6Count:     units[6],
                                unit7Count:     units[7],
                                unit8Count:     units[8],
                                unit9Count:     units[9],
                                unit10Count:     units[10],
                                unit11Count:     units[11],
                                unit12Count:     units[12],
                            });
                            
                            var troops = Seed.units["city" + cityId];
                            for (var u = 1; u <= 12; ++u) {
                                var troop_number = parseInt(rslt["unit" + u + "Return"]);
                                if (isNaN(troop_number)) {
                                    troop_number = parseInt(Seed.units["city" + cityId]["unt" + u]);
                                } else troop_number = parseInt(rslt["unit" + u + "Return"]) + parseInt(Seed.units["city" + cityId]["unt" + u]);
                                troops["unt" + u] = troop_number;
                            }
                            
                            setTimeout (function (){GM_setValue ('SavedRaids_'+serverID, JSON2.stringify(t.save));}, 0);
                          unsafeWindow.cityinfo_army();      
                          setTimeout(unsafeWindow.update_seed_ajax, 250);
                        }
                 },
         });
                 t.stopprogress = count * (100/t.count);
                 actionLog('Deleting: '+ Seed.cities[city][1]);
                 if (t.stopprogress.toFixed(0) == 100) {
                      t.stopprogress = 0;
                      t.GetRaids(cityId);
      }    
         
},
  
      
  DeleteCityRaids : function (){
          var t = Tabs.Raid;
          alert('This button needs to be added...');
          /*var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  
          
          params.pf = 0;
          params.ctrl = 'BotManager';
          params.action = 'stopAll';
          params.settings = {};
  
            params.settings.cityId = t.cityId;
                    
           new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                        method: "post",
                       parameters: params,
                       loading: true,
                       onSuccess: function(transport){
                          var rslt = eval("(" + transport.responseText + ")");
                            if (rslt.ok) {
                                    
                            }
                       },
               }); */       
      },
        
        
  AddRaid : function (Id){
        var t = Tabs.Raid;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        update = {};
        
        params.pf = 0;
        params.ctrl = 'BotManager';
        params.action = 'saveMarch';
        params.settings = {};
        params.queue = {0:{botMarches:{botMarchStatus:1,botState:1},cityMarches:{}}};
        
        for (y in t.save){
            if (t.save[y]['marchId'] == Id){
                params.settings.cityId = t.save[y]['cityId'];
                params.queue[0].cityMarches.knightId = t.save[y]['knightId']; //parseInt(document.getElementById('AddKnights').value);
                params.queue[0].cityMarches.toXCoord = t.save[y]['toXCoord'];
                params.queue[0].cityMarches.toYCoord = t.save[y]['toYCoord'];
                params.queue[0].cityMarches.unit0Count = 0;
                params.queue[0].cityMarches.unit1Count = t.save[y]['unit1Count'];
                params.queue[0].cityMarches.unit2Count = t.save[y]['unit2Count'];
                params.queue[0].cityMarches.unit3Count = t.save[y]['unit3Count'];
                params.queue[0].cityMarches.unit4Count = t.save[y]['unit4Count'];
                params.queue[0].cityMarches.unit5Count = t.save[y]['unit5Count'];
                params.queue[0].cityMarches.unit6Count = t.save[y]['unit6Count'];
                params.queue[0].cityMarches.unit7Count = t.save[y]['unit7Count'];
                params.queue[0].cityMarches.unit8Count = t.save[y]['unit8Count'];
                params.queue[0].cityMarches.unit9Count = t.save[y]['unit9Count'];
                params.queue[0].cityMarches.unit10Count = t.save[y]['unit10Count'];
                params.queue[0].cityMarches.unit11Count = t.save[y]['unit12Count'];
                params.queue[0].cityMarches.unit12Count = t.save[y]['unit12Count'];
            }
        }    
         
         
         new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                      method: "post",
                     parameters: params,
                     loading: true,
                     onSuccess: function(transport){
                        var rslt = eval("(" + transport.responseText + ")");
                          if (rslt.ok) {
                                t.GetRaids(params.settings.cityId);
                                  unsafeWindow.cityinfo_army();
                                    setTimeout(unsafeWindow.update_seed_ajax, 250);
                                    for (yy=0;yy<t.save.length;yy++){
                                        if (t.save[yy]['marchId'] == Id){
                                              t.save.splice (yy,1);
                                        }    
                                    }
                                    var serverID = getServerId();
                                    setTimeout (function (){GM_setValue ('SavedRaids_'+serverID, JSON2.stringify(t.save));}, 0);
                                    t.paint();
                         } else {
                                 logit('Error: '+ rslt.msg);      
                         }
                     },
             });        
    },
    
        
  getKnights : function(cityId){
         var t = Tabs.Raid;
         var knt = new Array();
         var status ="";
         for (k in Seed.knights['city' + cityId]){
                 if ( Seed.leaders['city' + cityId]["resourcefulnessKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["politicsKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["combatKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["intelligenceKnightId"] != Seed.knights['city' + cityId][k]["knightId"]){
                    if (Seed.knights['city' + cityId][k]["knightStatus"] == 1 ) status = "Free";
                    else status = "Marching";
                     knt.push ({
                         Name:   Seed.knights['city' + cityId][k]["knightName"],
                         Combat:    parseInt(Seed.knights['city' + cityId][k]["combat"]),
                         ID:        Seed.knights['city' + cityId][k]["knightId"],
                         Status: status,
                     });
                 }
         }
         knt = knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
         document.getElementById('AddKnights').options.length=0;
          var o = document.createElement("option");
          o.text = '--Choose a Knight--';
          o.value = 0;
          document.getElementById("AddKnights").options.add(o);
         for (k in knt){
                  if (knt[k]["Name"] !=undefined){
                      var o = document.createElement("option");
                      o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +') (' + knt[k]["Status"] +')');
                      o.value = knt[k]["ID"];
                      document.getElementById("AddKnights").options.add(o);
                  }
          }
      },
  
    
  clickCitySelect : function (city){
      var t = Tabs.Raid;
      t.cityId = city['id'];
      t.GetRaids(t.cityId);
  },
  
  checkRaids : function (){
    var t = Tabs.Raid;
    var now = unixTime();
    if(!Options.RaidRunning) return;
    if ( (now - Options.RaidReset) > 7200 ) {
        Options.RaidReset = now;
        saveOptions();
        for (g=0;g<Seed.cities.length;g++){
                t.citiesdone = "";
                setTimeout(t.resetRaids, (1500*g), Seed.cities[g][0],Seed.cities[g][1]);
        }
        setTimeout(t.postLog, 30000);
    }
    t.raidtimer = setTimeout(t.checkRaids, 900000);
  },
  
  GetRaids : function(cityId){
          var t = Tabs.Raid;
          var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                    
          params.pf = 0;
          params.ctrl = 'BotManager';
          params.action = 'getMarches';
          params.settings = {};
          params.settings.cityId = cityId;
          
          	
           new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                   method: "post",
                   parameters: params,
                   loading: true,
                   onSuccess: function(transport){
                      var rslt = eval("(" + transport.responseText + ")");
                        if (rslt.ok) {
                            t.rslt = rslt;
                              t.paint();
                              unsafeWindow.cityinfo_army();
                              setTimeout(unsafeWindow.update_seed_ajax, 250);
                          }
                   },
           });
  },
  
  
  resetRaids : function(cityId,cityName){
          var t = Tabs.Raid;
          var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                    
          params.pf = 0;
          params.ctrl = 'BotManager';
          params.action = 'resetRaidTimer';
        params.settings = {};
          params.settings.cityId = cityId;
          
          
           new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                   method: "post",
                   parameters: params,
                 loading: true,
                 onSuccess: function(transport){
                    var rslt = eval("(" + transport.responseText + ")");
                        if (rslt.ok) {
                            unsafeWindow.cityinfo_army();
                            setTimeout(unsafeWindow.update_seed_ajax, 250);
                            t.citiesdone += cityName + ' ';
                        }
                 },
           });
  },
  
  postLog : function (){
          var t = Tabs.Raid;
          actionLog('Reset Raidtimer: ' + t.citiesdone);
  },
  
  sendreport: function(){
      var t = Tabs.Raid;
      if(!Options.foodreport) return;
      var now = new Date().getTime()/1000.0;
      now = now.toFixed(0);
      if (now < (parseInt(Options.LastReport)+(Options.MsgInterval*60*60))) return;
    
    var total = 0;
    var message = 'Raid Stats: %0A';
    message += '%0A Food Gain (for '+ Options.MsgInterval +' hour of raiding) %0A';
    for (q=1;q<=Seed.cities.length;q++){
        var cityID = 'city' + Seed.cities[q-1][0];
        var gain = parseInt(Seed.resources[cityID]['rec1'][0] / 3600) - Options.Foodstatus[q];
        message+= Seed.cities[q-1][1] + ': Start: ' + addCommas(Options.Foodstatus[q]) + ' End :' + addCommas(parseInt(Seed.resources[cityID]['rec1'][0] / 3600)) + ' Gain: ';
        message += addCommas(gain)  + '%0A';
        total += gain;
        Options.Foodstatus[q] = parseInt(Seed.resources[cityID]['rec1'][0] / 3600);
    }
    message += '%0A Total food gain : '+addCommas(total)+'%0A';
    
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.emailTo = Seed.player['name'];
    params.subject = "Raid Overview";
    params.message = message;
    params.requestType = "COMPOSED_MAIL";
    
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (message) {
            var rslt = eval("(" + message.responseText + ")");
            if (rslt.ok) {
            } else {
            }
        },
        onFailure: function () {
        },
    });
    
    Options.LastReport = now;
    saveOptions();
  },
  
  toggleRaidState : function (){
      var t = Tabs.Raid;
      if(Options.RaidRunning){
          Options.RaidRunning = false;
          t.raidtimer = null;
          document.getElementById('pbRaidStart').value = 'Auto Reset = OFF';
      } else {
          Options.RaidRunning = true;
          t.raidtimer = setTimeout(t.checkRaids, 5000);
          document.getElementById('pbRaidStart').value = 'Auto Reset = ON';
      }
      saveOptions();
  },

  hide : function (){
  },

  show : function (){
  },
 };


/*************************** Auto Craft Tab *************************************/
var CraftTabActive = false;

Tabs.AutoCraft = {
    tabOrder: 20,
    tabLabel: "Auto Craft",
    myDiv: null,
    init: function(div){
    	var t = Tabs.AutoCraft;
      	t.myDiv = div;
      	unsafeWindow.CraftClick = t.CraftClick;
      	if (CraftOptions.cap=="") t.MakeOptions();
      	if (CraftOptions.until=="") t.MakeExtraOptions();
      	var m = '<DIV class=pbStat>AUTOMATED CRAFTING FUNCTION</div><TABLE width=100% height=0% class=pbTab><TR align="center">';
      	m+='<TD><INPUT class="buttonDash_'+ (CraftOptions.Running?'ON':'OFF') +'" id=pbCraftRunning type=submit value="'+translate("Crafting")+' = '+ (CraftOptions.Running?'ON':'OFF')+'"></td>';
       m += '<td align=left><INPUT id=pbat2TR type=checkbox '+(TrainOptions.tr2?'CHECKED':'')+'> '+translate('Only craft when throne room set')+' <INPUT id=pbat2TRset type=text size=2 maxlength=2 value="'+ TrainOptions.trset2 +'">  '+translate('is equiped') +'</td>';
      	m+='<TD><span id=CraftFrom></span></td></tr>';
      	m+='</tr></table><DIV id=CraftStats></div><DIV id=CraftBody></div>';
      	t.myDiv.innerHTML = m;
      	t.from = new CdispCityPicker ('pbCraftFrom', document.getElementById('CraftFrom'), true, t.ClickCitySelect, 0); 
      	t.PaintCraftItems();
      	document.getElementById('pbCraftRunning').addEventListener('click', t.toggleStateRunning , false);
         document.getElementById('pbat2TR').addEventListener ('change', function() {
        TrainOptions.tr2 = this.checked;
        saveTrainOptions();
        }, false);
    document.getElementById('pbat2TRset').addEventListener ('change', function() {
        TrainOptions.trset2 = this.value;
        saveTrainOptions();
        }, false); 
	},
	toggleStateRunning: function(obj){
		var t = Tabs.AutoCraft;
		if (CraftOptions.Running == true) {
			CraftOptions.Running = false;
			saveCraftOptions();
			if (document.getElementById('pbCraftRunning')) {document.getElementById('pbCraftRunning').value = "Crafting = OFF";document.getElementById('pbCraftRunning').setAttribute("class", "buttonDash_OFF");}
			if (document.getElementById('CraftToggle')) {document.getElementById('CraftToggle').value = "Crafting = OFF";document.getElementById('CraftToggle').setAttribute("class", "buttonDash_OFF");}
		}
		else {
		      CraftOptions.Running = true;
		      saveCraftOptions();
		      if (document.getElementById('pbCraftRunning')) {document.getElementById('pbCraftRunning').value = "Crafting = ON";document.getElementById('pbCraftRunning').setAttribute("class", "buttonDash_ON");}
		      if (document.getElementById('CraftToggle')) {document.getElementById('CraftToggle').value = "Crafting = ON";document.getElementById('CraftToggle').setAttribute("class", "buttonDash_ON");}
		      t.CraftCylce();
		}
		t.PaintCraftItems();
    },
	PaintStats:function(){
		var t = Tabs.AutoCraft;
		var m='<TABLE class=pbTab width=95%><TR><TD><B>City:</b></td>';
		var now=unixTime();
		for (var ii=0;ii<Seed.cities.length;ii++) m+='<TD style="text-align:right;"><INPUT id="CraftCity_'+Seed.cities[ii][0]+'" '+(CraftOptions.City[ii]?'checked=true':'unchecked=true')+' type=checkbox><B> '+ Seed.cities[ii][1] + '</b></td>';
		m+='</tr><TR><TD><B>Item:</b></td>';	
		for (var ii=0;ii<Seed.cities.length;ii++) {
			if (Seed.queue_craft['city'+Seed.cities[ii][0]][0]==undefined) m+='<TD style="text-align:right;">----</td>';
			 else {
			 	for (var y=0;y<unsafeWindow.recipelist['1'].length;y++) if (unsafeWindow.recipelist['1'][y].recipe_id == Seed.queue_craft['city'+Seed.cities[ii][0]][0].recipeId) m+='<TD style="text-align:right;">'+ unsafeWindow.itemlist['i'+unsafeWindow.recipelist['1'][y].output_item_id].name + '</td>';
			 	for (var y=0;y<unsafeWindow.recipelist['3'].length;y++) if (unsafeWindow.recipelist['3'][y].recipe_id == Seed.queue_craft['city'+Seed.cities[ii][0]][0].recipeId) m+='<TD style="text-align:right;">'+ unsafeWindow.itemlist['i'+unsafeWindow.recipelist['3'][y].output_item_id].name + '</td>';
			 }
		}
		m+='</tr><TR><TD><B>Time:</b></td>';	
		for (var ii=0;ii<Seed.cities.length;ii++) {
     		if (getCityBuilding(Seed.cities[ii][0],20).count>0) {
     			if (Seed.queue_craft['city'+Seed.cities[ii][0]]!=null && Seed.queue_craft['city'+Seed.cities[ii][0]].length>0) {
     				var CraftTime = Seed.queue_craft['city'+Seed.cities[ii][0]][0].craftingEtaUnixTime - now;
     				if (CraftTime<0) CraftTime=0;
     				if (CraftTime == 0) m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
					 else m+='<TD style="text-align:right;">'+timestr(CraftTime)+'</td>';
     			} else m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
     		} else m+='<TD style="text-align:right;">----</td>';
     	}
     	m+='</tr><TR><TD><B>Aetherstones:</b></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) m+='<TD style="text-align:right;">'+ addCommas(parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec5'][0])) + '</td>';
     	m+='</tr></table>';
     	document.getElementById('CraftStats').innerHTML = m;
     	for (var ii=0;ii<Seed.cities.length;ii++) document.getElementById('CraftCity_'+Seed.cities[ii][0]).addEventListener('click', t.saveCraftOptions , false);
	},
	PaintCraftItems:function(){
		var t=Tabs.AutoCraft;
		var m='<DIV class=pbStat>ITEM LIST (Click on item icon to manualy craft!)</div><DIV id="CraftItems" style="max-height:600px;overflow:auto;">';
      	m+= '<TABLE class=pbTab width=95%><TR valign=top><TD><DIV id=CraftLeft></div></td><TD width=30px>&nbsp</td><TD style="width:30px;border-left: 1px solid black;">&nbsp</td><TD><DIV id=CraftRight></div></td></tr></table>';  	
      	var left=right= '<TABLE width=100% class=pbTab>';
      	var Counter=1;
      	for(var i=0; i < unsafeWindow.recipelist[1].length; i++) {
      	 	Counter++;
      	 	var cont ='<TR><TD style="width:60px;vertical-align:middle" rowspan="3"><a class=hasTooltip onclick="CraftClick('+i+',1)"><img style="width:50px" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+ unsafeWindow.recipelist[1][i].output_item_id + '.jpg">';
      	 	cont+='<SPAN><img style="width:25px;vertical-align:middle;" src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_70.png">&nbsp'+addCommas(parseInt(unsafeWindow.recipelist[1][i].input.resources[1]))+'</span></a></td></tr>';
      	 	cont+='<TR valign=top><TD colspan=2>'+((Seed.items['i'+unsafeWindow.recipelist[1][i].output_item_id])?Seed.items['i'+unsafeWindow.recipelist[1][i].output_item_id]:0)+' '+unsafeWindow.itemlist['i'+unsafeWindow.recipelist[1][i].output_item_id].name+'</td>';
      	 	cont+='<TD colspan=4><INPUT id="Craft_'+unsafeWindow.recipelist[1][i].recipe_id+'" '+(CraftOptions.enabled[unsafeWindow.recipelist[1][i].recipe_id]?'checked=true':'unchecked=true')+' type=checkbox>';
      	 	cont+='<SELECT id="CraftMethod_'+unsafeWindow.recipelist[1][i].recipe_id+'"><OPTION value="false">Craft</option><OPTION value="true">Craft untill</option></select>';
      	 	cont+='<INPUT id="CraftNumber_'+unsafeWindow.recipelist[1][i].recipe_id+'" type=text size=4 maxlength=4 value="'+CraftOptions.cap[unsafeWindow.recipelist[1][i].recipe_id]+'"> items</td></tr><TR>';
      	 	for (var y in unsafeWindow.recipelist[1][i].input.items) if(y>0) {
      	 		var inventory = Seed.items['i'+y];
      	 		if (inventory==undefined) inventory=0;
      	 		color = ((parseInt(unsafeWindow.recipelist[1][i].input.items[y]) <= inventory)?'BLACK':'RED');
      	 		cont+='<TD style="text-align:center"><a class="hasTooltip"><img style="width:25px;vertical-align:middle;" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+ y + '.jpg">';
      	 		cont+='<SPAN>'+unsafeWindow.itemlist['i'+y].name+'</span></a>';
      	 		cont+='<FONT color='+color+'> '+unsafeWindow.recipelist[1][i].input.items[y]+'/'+inventory+'</font></td>';
      	 	}
      	 	cont+='</tr>';
      	 	if (Counter%2==0) left+=cont;
      	 	 else right+=cont;
      	}
		for(var i=0; i < unsafeWindow.recipelist[3].length; i++) {
      	 	Counter++;
      	 	var cont ='<TR><TD style="width:60px;vertical-align:middle" rowspan="3"><a class=hasTooltip onclick="CraftClick('+i+',1)"><img style="width:50px" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+ unsafeWindow.recipelist[3][i].output_item_id + '.jpg">';
      	 	cont+='<SPAN><img style="width:25px;vertical-align:middle;" src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_70.png">&nbsp'+addCommas(parseInt(unsafeWindow.recipelist[3][i].input.resources[1]))+'</span></a></td></tr>';
      	 	cont+='<TR valign=top><TD colspan=2>'+((Seed.items['i'+unsafeWindow.recipelist[3][i].output_item_id])?Seed.items['i'+unsafeWindow.recipelist[3][i].output_item_id]:0)+' '+unsafeWindow.itemlist['i'+unsafeWindow.recipelist[3][i].output_item_id].name+'</td>';
      	 	cont+='<TD colspan=4><INPUT id="Craft_'+unsafeWindow.recipelist[3][i].recipe_id+'" '+(CraftOptions.enabled[unsafeWindow.recipelist[3][i].recipe_id]?'checked=true':'unchecked=true')+' type=checkbox>';
      	 	cont+='<SELECT id="CraftMethod_'+unsafeWindow.recipelist[3][i].recipe_id+'"><OPTION value="false">Craft</option><OPTION value="true">Craft untill</option></select>';
      	 	cont+='<INPUT id="CraftNumber_'+unsafeWindow.recipelist[3][i].recipe_id+'" type=text size=4 maxlength=4 value="'+CraftOptions.cap[unsafeWindow.recipelist[3][i].recipe_id]+'"> items</td></tr><TR>';
      	 	for (var y in unsafeWindow.recipelist[3][i].input.items) if(y>0) {
      	 		var inventory = Seed.items['i'+y];
      	 		if (inventory==undefined) inventory=0;
      	 		color = ((parseInt(unsafeWindow.recipelist[3][i].input.items[y]) <= inventory)?'BLACK':'RED');
      	 		cont+='<TD style="text-align:center"><a class="hasTooltip"><img style="width:25px;vertical-align:middle;" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+ y + '.jpg">';
      	 		cont+='<SPAN>'+unsafeWindow.itemlist['i'+y].name+'</span></a>';
      	 		cont+='<FONT color='+color+'> '+unsafeWindow.recipelist[3][i].input.items[y]+'/'+inventory+'</font></td>';
      	 	}
      	 	cont+='</tr>';
      	 	if (Counter%2==0) left+=cont;
      	 	 else right+=cont;
      	}
      	left+='</table>';
      	right+='</table>';
      	document.getElementById('CraftBody').innerHTML = m;
      	document.getElementById('CraftLeft').innerHTML = left;
      	document.getElementById('CraftRight').innerHTML = right;
    	for(var i=0; i < unsafeWindow.recipelist[1].length; i++) {
    		document.getElementById('Craft_'+unsafeWindow.recipelist[1][i].recipe_id).addEventListener('click', t.saveCraftOptions , false);
    		document.getElementById('CraftMethod_'+unsafeWindow.recipelist[1][i].recipe_id).addEventListener('change', t.saveCraftOptions , false);
    		document.getElementById('CraftNumber_'+unsafeWindow.recipelist[1][i].recipe_id).addEventListener('change', t.saveCraftOptions , false);
    		document.getElementById('CraftMethod_'+unsafeWindow.recipelist[1][i].recipe_id).value= CraftOptions.until[unsafeWindow.recipelist[1][i].recipe_id];

    	}
    	for(var i=0; i < unsafeWindow.recipelist[3].length; i++) {
    		document.getElementById('Craft_'+unsafeWindow.recipelist[3][i].recipe_id).addEventListener('click', t.saveCraftOptions , false);
    		document.getElementById('CraftMethod_'+unsafeWindow.recipelist[3][i].recipe_id).addEventListener('change', t.saveCraftOptions , false);
    		document.getElementById('CraftNumber_'+unsafeWindow.recipelist[3][i].recipe_id).addEventListener('change', t.saveCraftOptions , false);
    		document.getElementById('CraftMethod_'+unsafeWindow.recipelist[3][i].recipe_id).value= CraftOptions.until[unsafeWindow.recipelist[3][i].recipe_id];
    	}	 
	},
	saveCraftOptions:function(){
		var t=Tabs.AutoCraft;
		for (var ii=0;ii<Seed.cities.length;ii++) CraftOptions.City[ii] = document.getElementById('CraftCity_'+Seed.cities[ii][0]).checked;
		for (var i=0;i<unsafeWindow.recipelist[1].length;i++) {
			CraftOptions.enabled[unsafeWindow.recipelist[1][i].recipe_id] = document.getElementById('Craft_'+unsafeWindow.recipelist[1][i].recipe_id).checked;
			CraftOptions.until[unsafeWindow.recipelist[1][i].recipe_id] = document.getElementById('CraftMethod_'+unsafeWindow.recipelist[1][i].recipe_id).value;
			CraftOptions.cap[unsafeWindow.recipelist[1][i].recipe_id] = document.getElementById('CraftNumber_'+unsafeWindow.recipelist[1][i].recipe_id).value;		
		}
		for (var i=0;i<unsafeWindow.recipelist[3].length;i++) {
			CraftOptions.enabled[unsafeWindow.recipelist[3][i].recipe_id] = document.getElementById('Craft_'+unsafeWindow.recipelist[3][i].recipe_id).checked;
			CraftOptions.until[unsafeWindow.recipelist[3][i].recipe_id] = document.getElementById('CraftMethod_'+unsafeWindow.recipelist[3][i].recipe_id).value;
			CraftOptions.cap[unsafeWindow.recipelist[3][i].recipe_id] = document.getElementById('CraftNumber_'+unsafeWindow.recipelist[3][i].recipe_id).value;
		}
    	saveCraftOptions();
	},
 	CraftClick:function(recipe,categoryId){
 		var t=Tabs.AutoCraft;
 		item = unsafeWindow.recipelist[categoryId][recipe];
 		if (Seed.queue_craft['city'+t.from.city.id].length>0)  {t.AlertPopup('You are already crafting in this city.');return;}
 		if (parseInt(item.input.resources['1']) >= (Seed.resources['city'+t.from.city.id]['rec5'][0])) {t.AlertPopup('You don\'t have enough Aetherstones.');return;}
 		for (var y in item.input.items) if(y>0) if (Seed.items['i'+y] < parseInt(item.input.items[y])) {t.AlertPopup('You don\'t have all the ingredients.');return;}
 		if (getCityBuilding(t.from.city.id,20).maxLevel < parseInt(item.requirements.building)) {t.AlertPopup('Spire level not high enough.');return;}
		if (getCityBuilding(t.from.city.id,20).count==0) return; 
 		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.ctrl = 'Crafting';
        params.action = 'craft';
        params.cityId = t.from.city.id;
        params.itemId = item.output_item_id;
        params.categoryId = categoryId;
        params.recipeId = item.recipe_id;
        params.insurance = false;
        new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (transport) {
              var rslt = eval("(" + transport.responseText + ")");
              if(rslt.ok) if(rslt.status == 'success') {
              	actionLog("Craft: " + rslt.status + " - " + item.name);
              	t.PaintCraftItems();
              	var add={};
               	add.recipeId=params.recipeId;
               	add.craftingUnixTime=rslt.time.startTime;
               	add.craftingEtaUnixTime=rslt.time.endTime;
               	add.craftingId=rslt.craftingId;
               	add.categoryId=categoryId;
               	add.recipeIndex=null;
               	unsafeWindow.seed.queue_craft["city"+params.cityId].push(add);
               	for (var y in item.input.items) unsafeWindow.seed.items['i'+y]-= parseInt(item.input.items[y]);
               	unsafeWindow.seed.resources['city'+params.cityId]['rec5'][0] -= item.input.resources['1'];
               	if (unsafeWindow.currentcityid == params.cityId) if (unsafeWindow.jQuery("#queue_head_building").hasClass("sel")) unsafeWindow.queue_changetab_building();
              } else {
              		for (var y in item.input.items) unsafeWindow.seed.items['i'+y]-= parseInt(item.input.items[y]);
               		unsafeWindow.seed.resources['city'+params.cityId]['rec5'][0] -= item.input.resources['1'];
               		unsafeWindow.seed.items['i'+item.consolation_item_id]++;
               		var msg = "Craft failed";
               		if (rslt.errorMessage) msg +=' (' +rslt.errorMessage+')';
               		if (item.consolation_item_id) msg+= ', you get a <img width=25 src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+ parseInt(item.consolation_item_id) + '.jpg">';
               		t.AlertPopup(msg);
              }
              t.PaintCraftItems();
            },
            onFailure: function () {
            },
        });   
 	},
 	AlertPopup:function(msg){
 		var t=Tabs.AutoCraft;
 		var pop = new pbPopup ('CraftAlert', 0, 0, 500, 100, true);
	    pop.centerMe (mainPop.getMainDiv());  
	    pop.getMainDiv().innerHTML = '<BR><DIV style="text-align:center"><B>'+msg+'</b></div><BR><BR><BR>';
	    pop.getTopDiv().innerHTML = '<CENTER><B>Crafting Alert</b></center>';
	    pop.show (true);
 	},
 	CraftCylce:function(){
 		var t=Tabs.AutoCraft;
    if (TrainOptions.tr2 && TrainOptions.trset2 != 0) {
    if (Seed.throne.activeSlot != TrainOptions.trset2) {
           setTimeout(t.nextcity, 20*1000); //train time lag?
            return; 
            };
 		for (var i=0;i<Seed.cities.length;i++) {
 			if (Seed.queue_craft['city'+Seed.cities[i][0]].length>0){
	 			var check = parseInt(Seed.queue_craft['city'+Seed.cities[i][0]][0].craftingEtaUnixTime)+5 - unixTime();
	 			var done = ((check>0)?false:true);
	 			if (done) Seed.queue_craft["city" + Seed.cities[i][0]].splice(0, 1);
	 		}
 		}
    }
 		for (var i=0;i<Seed.cities.length;i++) if (Seed.queue_craft['city'+Seed.cities[i][0]].length==0) setTimeout(t.CheckCity,2500*i,i);
 	},
 	CheckCity:function(city){
 		var t=Tabs.AutoCraft;
 		for (var y=unsafeWindow.recipelist[3].length-1;y>=0;y--){
 				var action = CraftOptions.until[unsafeWindow.recipelist[3][y].recipe_id];
	 			var ok = t.IngredientsCheck(unsafeWindow.recipelist[3][y],Seed.cities[city][0]);
	 			if (ok) {t.doCraft(unsafeWindow.recipelist[3][y],Seed.cities[city][0],Seed.cities[city][1],city,2,action);return;}
 		}
 		for (var y=unsafeWindow.recipelist[1].length-1;y>=0;y--){
  				var action = CraftOptions.until[unsafeWindow.recipelist[1][y].recipe_id];
	 			var ok = t.IngredientsCheck(unsafeWindow.recipelist[1][y],Seed.cities[city][0]);
	 			if (ok) {t.doCraft(unsafeWindow.recipelist[1][y],Seed.cities[city][0],Seed.cities[city][1],city,1,action);return;}
 		}
 	},
 	IngredientsCheck:function(item,cityId){
 		var t=Tabs.AutoCraft;
 		var inventory = t.getInventory(item);
 		if (CraftOptions.City[cityId]==false) return false;
 		if (CraftOptions.enabled[item.recipe_id]==false) return false;		 		
 		if (parseInt(item.input.resources['1']) >= (Seed.resources['city'+cityId]['rec5'][0])) return false;
 		for (var y in item.input.items) if(y>0) if (Seed.items['i'+y] < parseInt(item.input.items[y])) return false;
 		if (getCityBuilding(cityId,20).maxLevel < parseInt(item.requirements.building)) return false;
		if (getCityBuilding(cityId,20).count==0) return false;	
		if (parseInt(CraftOptions.cap[item.recipe_id])==0) return false;
		if (CraftOptions.until[item.recipe_id]=="true" && inventory >= parseInt(CraftOptions.cap[item.recipe_id])) return false;		
		return true;
 	},
 	getInventory:function(item){
 		var inventory = parseInt(Seed.items['i'+item.output_item_id]);
 		if (inventory==undefined) inventory =0;
 		for (var i=0;i<Seed.cities.length;i++) if (Seed.queue_craft['city'+Seed.cities[i][0]].length>0) if (parseInt(Seed.queue_craft['city'+Seed.cities[i][0]][0].recipeId) == parseInt(item.recipe_id)) inventory++;
 		return inventory;
 	},
 	doCraft:function(item,cityId,cityName,city,categoryId,action){
 		var t=Tabs.AutoCraft;
 		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.ctrl = 'Crafting';
        params.action = 'craft';
        params.cityId = cityId;
        params.itemId = item.output_item_id;
        params.categoryId = categoryId;
        params.recipeId = item.recipe_id;
        params.insurance = false;
        
        new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (transport) {
              var rslt = eval("(" + transport.responseText + ")");
              if(rslt.ok) if(rslt.status == 'success') {
              	actionLog("Craft in " +cityName + ': ' + rslt.status + " - " + item.name);
              	var add={};
               	add.recipeId=params.recipeId;
               	add.craftingUnixTime=rslt.time.startTime;
               	add.craftingEtaUnixTime=rslt.time.endTime;
               	add.craftingId=rslt.craftingId;
               	add.categoryId=categoryId;
               	add.recipeIndex=null;
               	unsafeWindow.seed.queue_craft["city"+params.cityId].push(add);
               	for (var y in item.input.items) unsafeWindow.seed.items['i'+y]-= parseInt(item.input.items[y]);
               	unsafeWindow.seed.resources['city'+params.cityId]['rec5'][0] -= item.input.resources['1'];
               	if (unsafeWindow.currentcityid == params.cityId) if (unsafeWindow.jQuery("#queue_head_building").hasClass("sel")) unsafeWindow.queue_changetab_building();
               	if (action=="false") CraftOptions.cap[item.recipe_id]--;
               	saveCraftOptions();
              } else {
              		for (var y in item.input.items) unsafeWindow.seed.items['i'+y]-= parseInt(item.input.items[y]);
               		unsafeWindow.seed.resources['city'+params.cityId]['rec5'][0] -= item.input.resources['1'];
               		unsafeWindow.seed.items['i'+item.consolation_item_id]++;
               		var msg = "Craft failed in " + cityName + " - " + item.name;
               		if (rslt.errorMessage) msg +=' (' +rslt.errorMessage+')';
               		if (item.consolation_item_id) msg+= ', you get a '+ unsafeWindow.itemlist['i'+item.consolation_item_id].name ;
               		actionLog(msg);
               		if (rslt.errorCode==null && rslt.errorMessage==null)t.CheckCity(city);
              }
              if (CraftTabActive) t.PaintCraftItems();
            },
            onFailure: function () {
            },
        });   
 	},
 	MakeOptions:function(){
 		var items = {};
 		var cap = {};
 		for(var i=0; i < unsafeWindow.recipelist[1].length; i++) cap[unsafeWindow.recipelist[1][i].recipe_id] = 0;
 		for(var i=0; i < unsafeWindow.recipelist[3].length; i++) cap[unsafeWindow.recipelist[3][i].recipe_id] = 0;
 		CraftOptions.cap= cap;
 		saveCraftOptions();
 	},
 	MakeExtraOptions:function(){
 		var enabled = {};
 		var until = {};
 		for(var i=0; i < unsafeWindow.recipelist[1].length; i++) enabled[unsafeWindow.recipelist[1][i].recipe_id] = false;
 		for(var i=0; i < unsafeWindow.recipelist[3].length; i++) enabled[unsafeWindow.recipelist[3][i].recipe_id] = false;
 		for(var i=0; i < unsafeWindow.recipelist[1].length; i++) until[unsafeWindow.recipelist[1][i].recipe_id] = true;
 		for(var i=0; i < unsafeWindow.recipelist[3].length; i++) until[unsafeWindow.recipelist[3][i].recipe_id] = true;
 		CraftOptions.enabled= enabled;
 		CraftOptions.until= until;
 		saveCraftOptions();
 	},
    hide : function (){CraftTabActive = false;},
	show : function (){CraftTabActive = true;},  
}



/*********************************  Cresting Tab ***********************************/
 Tabs.Crest = {
  tabOrder : 70,
  myDiv : null,
  rallypointlevel:null,
  error_code: 0,
  knt:{},

     
  init : function (div){
    var t = Tabs.Crest;
    t.myDiv = div;
    var selbut=0;
    var m = '<DIV id=pbTowrtDivF class=pbStat>AUTOMATED CRESTING FUNCTION</div><TABLE id=pbcrestfunctions width=100% height=0% class=pbTab><TR align="center">';
    m+='<TD><INPUT class="buttonDash_'+ (CrestOptions.Running?'ON':'OFF') +'" id=Cresttoggle type=submit value="'+translate("Crest")+' = '+ (CrestOptions.Running?'ON':'OFF')+'"></td>';
    m += '<TD><INPUT id=CrestHelp type=submit class=pbButton value="HELP"></td><TD>Rallypoint options in options tab!</td></table>';
    m += '<DIV id=pbOpt class=pbStat>CRESTING OPTIONS</div>';
    m += '<B>This tab crests 1 wild from 1 city with abandon!! TO CREST PLAYERS/BARBS/WILDS with 1 wave for TR items, use ATTACK TAB...</b><BR><BR>';
    m +='<TABLE id=pbcrestopt	 width=100% height=0% class=pbTab><TR align="center"></table>';
    m += '<DIV style="margin-bottom:10px;">Crest from city: <span id=crestcity></span></div>';    
    m += '<TABLE class=pbTab><TR><TD>Wild coords: X:<INPUT id=pbcrestx type=text size=3 maxlength=3 value="'+CrestOptions.X+'"</td>';
    m += '<TD>Y:<INPUT id=pbcresty type=text size=3 maxlength=3 value="'+CrestOptions.Y+'"</td></tr></table>';   
    m += '<TABLE class=pbTab><TR><TD>Wave <b>1</b>: </td><TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_2_50.jpg?6545?6545></td><TD><INPUT id=R1MM type=text size=5 maxlength=5 value="'+CrestOptions.R1MM+'" (When left 0 it will not send out a first wave, for whatever reason you want to do that...)</td>';
    m += '</td><TD></td><TD><TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_10_50.jpg?6545?6545></td><TD><INPUT id=R1Ball type=text size=5 maxlength=5 value="'+CrestOptions.R1Ball+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_12_50.jpg?6545?6545></td><TD><INPUT id=R1Cat type=text size=5 maxlength=5 value="'+CrestOptions.R1Cat+'"</td></tr>';    
    m += '<TR><TD>Wave <b>2</b>: </td><TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_2_50.jpg?6545?6545></td><TD><INPUT id=R2MM type=text size=5 maxlength=5 value="'+CrestOptions.R2MM+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_4_50.jpg?6545?6545></td><TD><INPUT id=R2Pike type=text size=5 maxlength=5 value="'+CrestOptions.R2Pike+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_5_50.jpg?6545?6545></td><TD><INPUT id=R2Sword type=text size=5 maxlength=5 value="'+CrestOptions.R2Sword+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_6_50.jpg?6545?6545></td><TD><INPUT id=R2Arch type=text size=5 maxlength=5 value="'+CrestOptions.R2Arch+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_10_50.jpg?6545?6545></td><TD><INPUT id=R2Ball type=text size=5 maxlength=5 value="'+CrestOptions.R2Ball+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_11_50.jpg?6545?6545></td><TD><INPUT id=R2Ram type=text size=5 maxlength=5 value="'+CrestOptions.R2Ram+'"</td>';
    m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_12_50.jpg?6545?6545></td><TD><INPUT id=R2Cat type=text size=5 maxlength=5 value="'+CrestOptions.R2Cat+'"</td></tr></table>';
      //               https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_1_50.jpg?6545?6545"
    t.myDiv.innerHTML = m;
    
    for (var i=0;i<Seed.cities.length;i++){
		if (CrestOptions.CrestCity == Seed.cities[i][0]){
			selbut=i;
			break;
		}
	}
		
    t.tcp = new CdispCityPicker ('crestcityselect', document.getElementById('crestcity'), true, t.clickCitySelect, selbut);
    
    if (CrestOptions.CrestCity == 0) {
    	CrestOptions.CrestCity = t.tcp.city.id
    	saveCrestOptions();
    }
         
    document.getElementById('crestcity').addEventListener('click', function(){CrestOptions.CrestCity = t.tcp.city.id;saveCrestOptions();} , false);
    document.getElementById('Cresttoggle').addEventListener('click', function(){t.toggleCrestState(this)} , false);
    document.getElementById('CrestHelp').addEventListener('click', function(){t.helpPop();} , false);
    document.getElementById('pbcrestx').addEventListener('change', function(){
    	CrestOptions.X = document.getElementById('pbcrestx').value;
    	t.StopCrest();
    	saveCrestOptions();
    } , false);
    document.getElementById('pbcresty').addEventListener('change', function(){
    	CrestOptions.Y = document.getElementById('pbcresty').value;
    	t.StopCrest();
    	saveCrestOptions();
    } , false);
    document.getElementById('R1MM').addEventListener('change', function(){CrestOptions.R1MM = document.getElementById('R1MM').value; saveCrestOptions()} , false);
    document.getElementById('R1Ball').addEventListener('change', function(){CrestOptions.R1Ball = document.getElementById('R1Ball').value; saveCrestOptions()} , false);
    document.getElementById('R1Cat').addEventListener('change', function(){CrestOptions.R1Cat = document.getElementById('R1Cat').value; saveCrestOptions()} , false);
    document.getElementById('R2MM').addEventListener('change', function(){CrestOptions.R2MM = document.getElementById('R2MM').value; saveCrestOptions()} , false);
    document.getElementById('R2Pike').addEventListener('change', function(){CrestOptions.R2Pike = document.getElementById('R2Pike').value; saveCrestOptions()} , false);
    document.getElementById('R2Sword').addEventListener('change', function(){CrestOptions.R2Sword = document.getElementById('R2Sword').value; saveCrestOptions()} , false);
    document.getElementById('R2Arch').addEventListener('change', function(){CrestOptions.R2Arch = document.getElementById('R2Arch').value; saveCrestOptions()} , false);
    document.getElementById('R2Ball').addEventListener('change', function(){CrestOptions.R2Ball = document.getElementById('R2Ball').value; saveCrestOptions()} , false);
    document.getElementById('R2Ram').addEventListener('change', function(){CrestOptions.R2Ram = document.getElementById('R2Ram').value; saveCrestOptions()} , false);
    document.getElementById('R2Cat').addEventListener('change', function(){CrestOptions.R2Cat = document.getElementById('R2Cat').value; saveCrestOptions()} , false);
  },
  
  helpPop : function (){
    var helpText = '<BR>The crest tab is designed to attack one wild over and over again.<BR>';
    helpText += 'It will attack a wild in 2 waves, abandon it and start over.<BR>';
    helpText += 'So make sure u have 1 FREE SLOT in your castle for a wild!<BR>';
    helpText += 'Just fill in the coordinates, troops and hit "ON".<BR><BR>';
    helpText += 'Troop numers (from KOC WIKI):<BR>';
    helpText += '<A target="_tab" href="http://koc.wikia.com/wiki/Wilderness">More can be found on Koc Wikia</a>';
    helpText += '<TABLE width=100%><TR><TD>Level</td><TD>Wave 1</td><TD>Wave 2</td><TD>Troop loses</td><TD>Min. Fletching</td></tr>';
    helpText += '<TR><TD>1</td><TD>n/a</td><TD>160 MM</td><TD>12 MM</td><TD>0</td></tr>';
    helpText += '<TR><TD>1</td><TD>n/a</td><TD>80 archers</td><TD>None</td><TD>1+</td></tr>';
    helpText += '<TR><TD>2</td><TD>5 MM</td><TD>130 archers</td><TD>1st Wave</td><TD>2+</td></tr>';
    helpText += '<TR><TD>3</td><TD>10 MM</td><TD>520 archers</td><TD>1st Wave</td><TD>3+</td></tr>';
    helpText += '<TR><TD>4</td><TD>20 MM</td><TD>1600 archers</td><TD>1st Wave</td><TD>4+</td></tr>';
    helpText += '<TR><TD>5</td><TD>50 MM</td><TD>2200 archers</td><TD>1st Wave</td><TD>6+</td></tr>';
    helpText += '<TR><TD>6</td><TD>100 MM</td><TD>3000 archers</td><TD>1st Wave</td><TD>7+</td></tr>';
    helpText += '<TR><TD>7</td><TD>150 MM</td><TD>6000 archers</td><TD>1st Wave</td><TD>8+</td></tr>';
    helpText += '<TR><TD>8</td><TD>299 MM + 1Bal</td><TD>9000 archers + 900 Bal</td><TD>1st Wave + 1 Archer</td><TD>9+</td></tr>';
    helpText += '<TR><TD>9</td><TD>599 MM + 1Bal</td><TD>13000 archers + 900 Bal</td><TD>1st Wave + 2 Archer</td><TD>10</td></tr>';
    helpText += '<TR><TD>10</td><TD>1199 MM + 1Cat</td><TD>35000 archers + 2500 Cat</td><TD>1st Wave + 6 Archer + 50 Cat</td><TD>10</td></tr></table>';
    
    var pop = new pbPopup ('giftHelp', 0, 0, 585, 400, true);
    pop.centerMe (mainPop.getMainDiv());  
    pop.getMainDiv().innerHTML = helpText;
    pop.getTopDiv().innerHTML = '<CENTER><B>AIO Script Help: Cresting</b></center>';
    pop.show (true);
  },

  StopCrest: function(){
		CrestOptions.Running = false;
		if (document.getElementById('Cresttoggle')) {document.getElementById('Cresttoggle').value = "Crest = OFF";document.getElementById('Cresttoggle').setAttribute("class", "buttonDash_OFF");}
		if (document.getElementById('CrestToggleD')) {document.getElementById('CrestToggleD').value = "Crest = OFF";document.getElementById('CrestToggleD').setAttribute("class", "buttonDash_OFF");}
		ClearMarchQueue("Crest");
		saveCrestOptions();
  },

  toggleCrestState: function(obj){
		var t = Tabs.Crest;
        if (CrestOptions.Running == true) {
            CrestOptions.Running = false;
            if (document.getElementById('Cresttoggle')) {document.getElementById('Cresttoggle').value = "Crest = OFF";document.getElementById('Cresttoggle').setAttribute("class", "buttonDash_OFF");}
            if (document.getElementById('CrestToggleD')) {document.getElementById('CrestToggleD').value = "Crest = OFF";document.getElementById('CrestToggleD').setAttribute("class", "buttonDash_OFF");}
            ClearMarchQueue("Crest");
            saveCrestOptions();
        }
        else {
            CrestOptions.Running = true;
            if (document.getElementById('Cresttoggle')) {document.getElementById('Cresttoggle').value = "Crest = ON";document.getElementById('Cresttoggle').setAttribute("class", "buttonDash_ON");}
            if (document.getElementById('CrestToggleD')) {document.getElementById('CrestToggleD').value = "Crest = ON";document.getElementById('CrestToggleD').setAttribute("class", "buttonDash_ON");}
            saveCrestOptions();
        }
    },
    
    getAtkKnight : function(cityID){
     var t = Tabs.Crest;
     t.knt = new Array();
     for (k in Seed.knights[cityID]){
     		if (Seed.knights[cityID][k]["knightStatus"] == 1 && Seed.leaders[cityID]["resourcefulnessKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["politicsKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["combatKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["intelligenceKnightId"] != Seed.knights[cityID][k]["knightId"]){
     			t.knt.push ({
     				Name:   Seed.knights[cityID][k]["knightName"],
     				Combat:	(parseInt(Seed.knights[cityID][k]["combat"])+((Seed.knights[cityID][k]["combatBoostExpireUnixtime"]>0)?(Math.floor(parseInt(Seed.knights[cityID][k]["combat"])*0.25)):0)),
     				ID:		Seed.knights[cityID][k]["knightId"],
     			});
     		}
     }
     t.knt = t.knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
  },
  
  getRallypointLevel: function(cityId){
    var t = Tabs.Crest;
    for (var o in Seed.buildings[cityId]){
  	var buildingType = parseInt(Seed.buildings[cityId][o][0]);
  	var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
  	if (buildingType == 12) t.rallypointlevel=parseInt(buildingLevel);
     }
  },
  
  
  FirstRound: function(){
      var t = Tabs.Crest;
      var buzy = false;
      if (!CrestOptions.Running) return;
      cityID = 'city' + CrestOptions.CrestCity;
      if (parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R1MM || parseInt(Seed.units[cityID]['unt10']) < CrestOptions.R1Ball || parseInt(Seed.units[cityID]['unt12']) < CrestOptions.R1Cat || parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R1MM || parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R2MM || parseInt(Seed.units[cityID]['unt4']) < CrestOptions.R2Pike || parseInt(Seed.units[cityID]['unt5']) < CrestOptions.R2Sword || parseInt(Seed.units[cityID]['unt6']) < CrestOptions.R2Arch || parseInt(Seed.units[cityID]['unt10']) < CrestOptions.R2Ball || parseInt(Seed.units[cityID]['unt11']) < CrestOptions.R2Ram || parseInt(Seed.units[cityID]['unt12']) < CrestOptions.R2Cat) return;
      for (var k in Seed.queue_atkp[cityID]) if (Seed.queue_atkp[cityID][k]['toXCoord']==CrestOptions.X && Seed.queue_atkp[cityID][k]['toYCoord']==CrestOptions.Y)  buzy=true;
      if (!buzy)  {
        CrestOptions.RoundOne=true;
        CrestOptions.RoundTwo=true;
        saveCrestOptions();
      }
      if(!CrestOptions.RoundOne) return;
      
      if (CrestOptions.R1MM == 0 && CrestOptions.R1Ball==0 && CrestOptions.R1Cat==0){
	      CrestOptions.RoundOne = false;
	      saveCrestOptions();
	      return;
      }
      
              
       var now = new Date().getTime()/1000.0;
       now = now.toFixed(0)
		
	   if (CrestOptions.R1MM > parseInt(Seed.units[cityID]['unt2']) || CrestOptions.R1Ball > parseInt(Seed.units[cityID]['unt10']) || CrestOptions.R1Cat > parseInt(Seed.units[cityID]['unt12'])){return;}
          
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        if (now < (parseInt(CrestOptions.lastRoundTwo) + 300)) { 
        	params.u2= (CrestOptions.R1MM / 10);
        	params.u2 = params.u2.toFixed(0);	
        	if (params.u2 < (CrestOptions.R1MM / 10)) params.u2++;
        }	
  		else params.u2= CrestOptions.R1MM;
  		params.u10=CrestOptions.R1Ball;
  		params.u12=CrestOptions.R1Cat;
  		
		for (i=1;i<=Seed.cities.length;i++) if (Seed.cities[i-1][0] == CrestOptions.CrestCity) var cityNumber = i;
		MarchQueue[cityNumber].push({
				what: 			"Crest",
				city:           CrestOptions.CrestCity,
                action:         4,
                targetX:        CrestOptions.X,
                targetY:        CrestOptions.Y,
                1:              0,
                2:              params.u2,
                3:              0,
                4:              0,
                5:              0,
                6:              0,
                7:              0,
                8:              0,
                9:              0,
                10:             params.u10,
                11:             0,
                12:             params.u12,
                13:             0,
                14:             0,
                15:             0,
                r1:             0,
                r2:             0,
                r3:             0,
                r4:             0,
                r5:             0,
                gold:           0,
        });

  		CrestOptions.RoundOne = false;
  		saveCrestOptions();
  		t.SecondRound();
  	 },
     
     	 
    SecondRound: function(){
      var t = Tabs.Crest;
      if (!CrestOptions.Running || !CrestOptions.RoundTwo) return;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      cityID = 'city' + CrestOptions.CrestCity;
      if (parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R1MM || parseInt(Seed.units[cityID]['unt10']) < CrestOptions.R1Ball || parseInt(Seed.units[cityID]['unt12']) < CrestOptions.R1Cat || parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R1MM || parseInt(Seed.units[cityID]['unt2']) < CrestOptions.R2MM || parseInt(Seed.units[cityID]['unt4']) < CrestOptions.R2Pike || parseInt(Seed.units[cityID]['unt5']) < CrestOptions.R2Sword || parseInt(Seed.units[cityID]['unt6']) < CrestOptions.R2Arch || parseInt(Seed.units[cityID]['unt10']) < CrestOptions.R2Ball || parseInt(Seed.units[cityID]['unt11']) < CrestOptions.R2Ram || parseInt(Seed.units[cityID]['unt12']) < CrestOptions.R2Cat) return;
      
   		params.u2=CrestOptions.R2MM;
  		params.u4=CrestOptions.R2Pike;
  		params.u5=CrestOptions.R2Sword;
  		params.u6=CrestOptions.R2Arch;
  		params.u10=CrestOptions.R2Ball;
  		params.u11=CrestOptions.R2Ram;
  		params.u12=CrestOptions.R2Cat;

  		for (i=1;i<=Seed.cities.length;i++) if (Seed.cities[i-1][0] == CrestOptions.CrestCity) var cityNumber = i;
		MarchQueue[cityNumber].push ({
						what: 			"Crest",
                        city:           CrestOptions.CrestCity,
                        action:         4,
                        targetX:        CrestOptions.X,
                        targetY:        CrestOptions.Y,
                        1:              0,
                        2:              params.u2,
                        3:              0,
                        4:              params.u4,
                        5:              params.u5,
                        6:              params.u6,
                        7:              0,
                        8:              0,
                        9:              0,
                        10:             params.u10,
                        11:             params.u11,
                        12:             params.u12,
                        13:             0,
                        14:             0,
                        15:             0,
                        r1:             0,
                        r2:             0,
                        r3:             0,
                        r4:             0,
                        r5:             0,
                        gold:           0,
        });

		CrestOptions.RoundTwo = false;
        var now = new Date().getTime()/1000.0;
        now = now.toFixed(0);
        CrestOptions.lastRoundTwo = now;
  		saveCrestOptions();
  	},
  		 
  		 
  	abandonWilderness: function(tid,x,y,cid){
      var t = Tabs.Crest;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      var cityID = cid;
	  var tileid = tid;
      params.tid=tid;
  	  params.cid=cid;
  	  params.x=x;
  	  params.y=y;
  	   		
  		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/abandonWilderness.php" + unsafeWindow.g_ajaxsuffix, {
  		         method: "post",
  		         parameters: params,
  		         loading: true,
  		         onSuccess: function (transport) {
  		         var rslt=eval("("+transport.responseText+")");
  		         
  		         
				  if (rslt.ok) {
				  	 t.error_code = 0;
				     CrestOptions.RoundOne = true;
				     CrestOptions.RoundTwo = true;
				     saveCrestOptions();
				      if (rslt.returningMarches) {
				          var cities = Object.keys(rslt.returningMarches);
				          for (var i = 0; i < cities.length; i++) {
				              for (var j = 0; j < rslt.returningMarches[cities[i]].length; j++) {
				                  var cid = cities[i].split("c")[1];
				                  var mid = rslt.returningMarches[cities[i]][j];
				                  var march = Seed.queue_atkp["city" + cid]["m" + mid];
				                  if (march) {
				                      var marchtime = Math.abs(parseInt(march.destinationUnixTime) - parseInt(march.marchUnixTime));
				                      var ut = unsafeWindow.unixtime();
				                      Seed.queue_atkp["city" + cid]["m" + mid].destinationUnixTime = ut;
				                      Seed.queue_atkp["city" + cid]["m" + mid].marchUnixTime = ut - marchtime;
				                      Seed.queue_atkp["city" + cid]["m" + mid].returnUnixTime = ut + marchtime;
				                      Seed.queue_atkp["city" + cid]["m" + mid].marchStatus = 8
				                  }
				              }
				          }
				      }
				      if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
				      
				      if (Object.keys(Seed.wilderness["city" + cityID]).length == 1) {
				          Seed.wilderness["city" + cityID] = []
  		         	  } else{
  		         	  	delete Seed.wilderness["city"+cityID]["t"+tileid];
  		         	  }
               } 
  		         },
  		         onFailure: function () {}
  		 });
    },
    
  hide : function (){
    var t = Tabs.Crest;
  },

  show : function (){
  },
 };



/*********************************** Dashboard Tab ***********************************/

function createDashboard (){
	var Dashboard = document.createElement('div');
	var beacon = document.getElementById('mod_cityinfo');
	Dashboard.id='Dash_div';
	Dashboard.style.position = 'relative';	
	if (GlobalOptions.pbWideScreenStyle=="ultra") Dashboard.style.width= "450px";
	 else if (GlobalOptions.pbWideScreenStyle=="wide") Dashboard.style.width= "400px";
	  else Dashboard.style.width = (screen.width - 1122 - 22) +"px";
	if (!Options.pbChatOnRight) Dashboard.style.width= "450px";
  	Dashboard.style.top = "-605px";
  	if (Options.pbChatOnRight) Dashboard.style.left ="1122px";
  	 else Dashboard.style.left ="760px";
  	Dashboard.style.height = "1100px";
  	Dashboard.style.background = '#FFFFE6';
  	Dashboard.style.overflow = 'auto';
	beacon.parentNode.insertBefore(Dashboard, beacon);
}

var DashboardOptions = {
	foodLevel:10000000000,
    woodLevel:1000000000,
    stoneLevel:100000000,
    oreLevel:100000000,
    astoneLevel:250000,
    showRP:true,
    showThrone:true,
    showStatus:true,
    showButtons:true,
    showReso:true,
    ShowResoCity:[true,true,true,true,true,true,true,true],
    ShowResoTypes:[null,true,true,true,true],
    showLog:true,
    showTroops:true,
    showTower:true,
    showWarnings:true,
    showMarches:true,
    showSacrifice:true,
}

var Dashboard = {
    tabOrder: 800,
    tabLabel: 'Dashboard',
    myDiv : null,
    Alerts: [],
    showMarchesInfo: true,
    
    init : function (div){
        var t = Dashboard;
        t.myDiv = div;
        Tabs.Reassign.readReassignState();
        Tabs.build.readBuildStates();

        createDashboard();

        if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") {
        	var m = '<div class="pbStat" id=dbHeader></div>';
	        m += '<TABLE class=pbTab cellspacing=0 cellpadding=0>';
	        m += '<TR><TD><INPUT id=AttackToggleD type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=CraftToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=TransportToggle type=submit class=pbButton style="width: 120px;"></td></tr>';
	        m += '<TR><TD><INPUT id=AutoDfToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutomercToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=CrestToggleD type=submit class=pbButton style="width: 120px;"></td></tr>';
	        m += '<TR><TD><INPUT id=AutotrainToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutoFarmToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=ReassignToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutoSalvageToggle type=submit class=pbButton style="width: 120px;"></td></tr>';        
	        m += '<TR><TD>&nbsp</td></tr><TR><TD><INPUT id=BuildToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=BuildModeToggle type=submit class=pbButton style="width: 120px;">&nbsp&nbsp<SPAN id=buildStatus style="vertical-align:bottom;"></span></td>';
	        m += '</table>';
	        m+='<BR><DIV id=MarchesSendInfo></div>';
	        m += '<BR><DIV id=CityStatus></div>';
	        m += '<BR><div class="pbStat">THRONE ROOM</div><DIV id=UpgradeStatus></div><DIV id=TriesStatus></div>';
	        m += '<BR><DIV id=ShowTrPresets></div>';
	        m += '<BR><DIV id=ShowRP></div>';
	        m += '<DIV id=SacrificePlaceholder></div>';
	        m += '<DIV id=TowerAlertPlaceholder></div>';
	        //m += '<BR><DIV id=ShowAutoTrain></div>';
	        m += '<BR><DIV id=ShowTroops></div>';     
	        m += '<DIV id=AlertsPlaceholder></div>';
	        m += '<DIV id=ShowMarches></div>'; 
	        m += '<BR><DIV id=ShowLog></div>';
        } else {
        	var m = '<div class="pbStat" id=dbHeader></div>';
	        m += '<TABLE width=100% class=pbTab cellspacing=0 cellpadding=0>';
	        m += '<TR><TD><INPUT id=AttackToggleD type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=CraftToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=TransportToggle type=submit class=pbButton style="width: 120px;"></td></tr>';
	        m += '<TR><TD><INPUT id=AutoDfToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutomercToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=CrestToggleD type=submit class=pbButton style="width: 120px;"></td></tr>';
	        m += '<TR><TD><INPUT id=AutotrainToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutoFarmToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=ReassignToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=AutoSalvageToggle type=submit class=pbButton style="width: 120px;"></td></tr>';        
	        m += '<TR><TD>&nbsp</td></tr><TR><TD><INPUT id=BuildToggle type=submit class=pbButton style="width: 120px;"></td></tr><TR><TD><INPUT id=BuildModeToggle type=submit class=pbButton style="width: 120px;">&nbsp&nbsp<SPAN id=buildStatus style="vertical-align:bottom;"></span></td>';
	        m += '</table>';
	        m+='<BR><DIV id=MarchesSendInfo></div>';
	        m += '<BR><DIV id=ShowTrPresets></div>';
	        m += '<DIV id=AlertsPlaceholder></div>'; 
        }
        document.getElementById('Dash_div').innerHTML = m;
        unsafeWindow.clearMarches = t.clearMarches;

        if (AtkOptions.Running) {document.getElementById('AttackToggleD').value = "Attack = ON";document.getElementById('AttackToggleD').setAttribute("class", "buttonDash_ON");}
        	else {document.getElementById('AttackToggleD').value = "Attack = OFF";document.getElementById('AttackToggleD').setAttribute("class", "buttonDash_OFF");}
        if (CraftOptions.Running) {document.getElementById('CraftToggle').value = "Crafting = ON";document.getElementById('CraftToggle').setAttribute("class", "buttonDash_ON");}
        	else {document.getElementById('CraftToggle').value = "Crafting = OFF";document.getElementById('CraftToggle').setAttribute("class", "buttonDash_OFF");}
        if (Tabs.transport.traderState.running) {document.getElementById('TransportToggle').value = "Transport = ON";document.getElementById('TransportToggle').setAttribute("class", "buttonDash_ON");}
        	else {document.getElementById('TransportToggle').value = "Transport = OFF"; document.getElementById('TransportToggle').setAttribute("class", "buttonDash_OFF");} 
        if (CrestOptions.Running) {document.getElementById('CrestToggleD').value = "Crest = ON";document.getElementById('CrestToggleD').setAttribute("class", "buttonDash_ON");}
    		else {document.getElementById('CrestToggleD').value = "Crest = OFF";document.getElementById('CrestToggleD').setAttribute("class", "buttonDash_OFF");}
    	if (DFOptions.Running) {document.getElementById('AutoDfToggle').value = "Auto DF = ON";document.getElementById('AutoDfToggle').setAttribute("class", "buttonDash_ON");}
    		else {document.getElementById('AutoDfToggle').value = "Auto DF = OFF";document.getElementById('AutoDfToggle').setAttribute("class", "buttonDash_OFF");}
         if (mercOptions.Running) {document.getElementById('AutomercToggle').value = "Auto merc = ON";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_ON");}
    		else {document.getElementById('AutomercToggle').value = "Auto merc = OFF";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_OFF");}
        
		if (TrainOptions.Running) {document.getElementById('AutotrainToggle').value = "AutoTrain = ON";document.getElementById('AutotrainToggle').setAttribute("class", "buttonDash_ON");}
			else {document.getElementById('AutotrainToggle').value = "AutoTrain = OFF";document.getElementById('AutotrainToggle').setAttribute("class", "buttonDash_OFF");}
		if (FarmOptions.Running) {document.getElementById('AutoFarmToggle').value = "Farming = ON";document.getElementById('AutoFarmToggle').setAttribute("class", "buttonDash_ON");}
			else {document.getElementById('AutoFarmToggle').value = "Farming = OFF";document.getElementById('AutoFarmToggle').setAttribute("class", "buttonDash_OFF");}
		if (Tabs.Reassign.reassignState.running) {document.getElementById('ReassignToggle').value = "Reassign = ON";document.getElementById('ReassignToggle').setAttribute("class", "buttonDash_ON");}
			else {document.getElementById('ReassignToggle').value = "Reassign = OFF";document.getElementById('ReassignToggle').setAttribute("class", "buttonDash_OFF");}
		if (Options.ThroneDeleteItems) {document.getElementById('AutoSalvageToggle').value = "Salvage = ON";document.getElementById('AutoSalvageToggle').setAttribute("class", "buttonDash_ON");}
			else {document.getElementById('AutoSalvageToggle').value = "Salvage = OFF";document.getElementById('AutoSalvageToggle').setAttribute("class", "buttonDash_OFF");}
		if (Tabs.build.buildStates.running=='ON') {document.getElementById('BuildToggle').value = "Auto Build = ON";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_ON");}
		if (Tabs.build.buildStates.running=='AUTO') {document.getElementById('BuildToggle').value = "Auto Build = AUTO";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_ON");}		
		if (Tabs.build.buildStates.running=='OFF') {document.getElementById('BuildToggle').value = "Auto Build = OFF";document.getElementById('BuildToggle').setAttribute("class", "buttonDash_OFF");}
		
		document.getElementById('BuildModeToggle').value = "Build Mode = OFF";
		document.getElementById('BuildModeToggle').setAttribute("class", "buttonDash_OFF"); 	
   // if (mercOptions.Running) {document.getElementById('AutomercToggle').value = "Auto merc = ON";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_ON");}
    //		else {document.getElementById('AutomercToggle').value = "Auto merc = OFF";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_OFF");}

		document.getElementById('buildStatus').innerHTML = '<img src=""/>';	 



        document.getElementById('AttackToggleD').addEventListener ('click', function(){Tabs.Attack.toggleAttackState();},false);
        document.getElementById('CraftToggle').addEventListener ('click', function(){Tabs.AutoCraft.toggleStateRunning(this);},false); 
        document.getElementById('TransportToggle').addEventListener ('click', function(){Tabs.transport.toggleTraderState(this);},false);
        document.getElementById('CrestToggleD').addEventListener ('click', function(){Tabs.Crest.toggleCrestState();},false);
        document.getElementById('AutoDfToggle').addEventListener ('click', function(){Tabs.DF.toggleDFState(this);},false); 
        document.getElementById('AutomercToggle').addEventListener ('click', function(){Tabs.merc.togglemercState(this);},false);  
        document.getElementById('AutotrainToggle').addEventListener ('click', function(){Tabs.AutoTrain.toggleAutoTrainState(this);},false);
        document.getElementById('AutoFarmToggle').addEventListener ('click', function(){Tabs.farm.toggleBarbState(this);},false);
        document.getElementById('ReassignToggle').addEventListener ('click', function(){Tabs.Reassign.toggleReassignState(this);},false);
        document.getElementById('AutoSalvageToggle').addEventListener ('click', function(){Tabs.Throne.ToggleSalvageState(this);},false);
        document.getElementById('BuildToggle').addEventListener ('click', function(){Tabs.build.toggleStateRunning(this);},false);
        document.getElementById('BuildModeToggle').addEventListener ('click', function(){Tabs.build.toggleStateMode(this);},false);
        
        if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") {
        	if (DashboardOptions.showWarnings) t.CheckForAlerts();
	        if (DashboardOptions.showThrone) t.ShowTrPresets();
	        t.RPM();
	        if (DashboardOptions.showStatus) t.CityStatus();
	        if (DashboardOptions.showTower) t.ShowTowerAlerts();
	        if (DashboardOptions.showLog) t.ShowLog();
	        if (DashboardOptions.showTroops) t.ShowTroops();
	        if (DashboardOptions.showSacrifice) t.showSacrifice();
	        t.ShowMarches();
	        //t.ShowAutoTrain();
        } else {
        	if (DashboardOptions.showThrone) t.ShowTrPresets();
	        t.RPM();
	        if (DashboardOptions.showWarnings) t.CheckForAlerts();
        }
    },

    CheckForAlerts: function (){
    	var t = Dashboard;
    	var foodLev = DashboardOptions.foodLevel
    	var woodLev = DashboardOptions.woodLevel
    	var stoneLev = DashboardOptions.stoneLevel
    	var oreLev = DashboardOptions.oreLevel
    	var astoneLev = DashboardOptions.astoneLevel
    	t.Alerts = [];
		for (var a=1; a<=5;a++) for(b=0; b<Cities.numCities; b++) {
			if (a==5) rec = Seed.resources["city" + Seed.cities[b][0]]['rec'+a][0];
				else rec = Math.round(Seed.resources["city" + Seed.cities[b][0]]['rec'+a][0]/3600);
    		switch (a){
    			case 1:if (rec < foodLev) t.Alerts.push(Seed.cities[b][1] + " (" + (b+1) +"): Food warning -> " + addCommas(rec));break;
    			case 2:	if (rec < woodLev) t.Alerts.push(Seed.cities[b][1] + " (" + (b+1) + "): Wood warning -> " + addCommas(rec));break;
    			case 3:	if (rec < stoneLev) t.Alerts.push(Seed.cities[b][1] + " (" + (b+1) + "): Stone warning -> " + addCommas(rec));break;
    			case 4:	if (rec < oreLev) t.Alerts.push(Seed.cities[b][1] + " (" + (b+1) + "): Ore warning -> " + addCommas(rec));break;
    			case 5:	if (rec < astoneLev) t.Alerts.push(Seed.cities[b][1] + " (" + (b+1) + "): Aetherstones warning -> " + addCommas(rec));break;
    		}
    	}
    	for(b=0; b<Seed.cities.length; b++) if (Seed.queue_unt["city" + Seed.cities[b][0]].length == 0) t.Alerts.push(Seed.cities[b][1] +  " (" + (b+1) + "): No troops training");

    	for(b=0; b<Seed.cities.length; b++) {
    		var check = false;
    		var tech = false;
    		var tech2 = false;
    		for (k in Seed.buildings["city" + Seed.cities[b][0]])	{
    			if (Seed.buildings["city" + Seed.cities[b][0]][k][1] < 9 && Seed.buildings["city" + Seed.cities[b][0]][k][2] < 500) if (Seed.queue_con["city" + Seed.cities[b][0]].length == 0 && Tabs.build["bQ_" + Seed.cities[b][0]].length == 0) check = true;
    			if (Seed.buildings["city" + Seed.cities[b][0]][k][0] == 11 && Seed.queue_tch["city" + Seed.cities[b][0]].length == 0) tech = true;
    			if (Seed.buildings["city" + Seed.cities[b][0]][k][0] == 27 && Seed.queue_tch2["city" + Seed.cities[b][0]].length == 0) tech2 = true;
    		}
    		if (check) t.Alerts.push(Seed.cities[b][1] +  " (" + (b+1) + "): No Buildqueue");
    		if (tech) t.Alerts.push(Seed.cities[b][1] +  " (" + (b+1) + "): No Reseach");
    		if (tech2) t.Alerts.push(Seed.cities[b][1] +  " (" + (b+1) + "): No Briton Reseach");
    	}
    	
    	var count = 0;
    	for (k in unsafeWindow.kocThroneItems) count++;
    	if (count > (Seed.throne.rowNum*5)) t.Alerts.push('Throne Room FULL (' + count + '/' + (Seed.throne.rowNum*5) +')');
    	
    	var msg="";
    	for (k=0;k<t.Alerts.length;k++) msg+= t.Alerts[k] + '<BR>';
    	if (t.Alerts.length > 0) {
    		document.getElementById('AlertsPlaceholder').innerHTML = '<BR><DIV class="pbStatOrange">Warnings</div><DIV id=ShowAlerts></div>'; //style="height: 60px; overflow: auto"
    		document.getElementById('ShowAlerts').innerHTML = msg;	
    	} else document.getElementById('AlertsPlaceholder').innerHTML = "";
    },
    

    ShowMarches: function (){
    	var t = Dashboard;
    	var msg= "";
    	t.showMarchesInfo = true;
    	if (MarchOptions.Queue.length > 0) {
    		msg = '<BR><DIV class="pbStat">Marches&nbsp&nbsp<INPUT type=submit class=pbButton id=HideMarches value=Hide></div><DIV id=MarchesInfo></div>';
    		document.getElementById('ShowMarches').innerHTML = msg;
    		msg = '<TABLE width=100% class=pbTab>';
    		msg +='<TR><TD>City</td><TD>Coords</td><TD>Target</td><TD>City</td><TD>Troops</td><TD>Action</td>';
    		for (k=0;k<MarchOptions.Queue.length;k++) {
    			var action = MarchOptions.Queue[k];
    			for (postcity in Seed.cities) if (Seed.cities[postcity][0] == action.city) logcity = Seed.cities[postcity][1];
			    var total = 0;
				var info = "";
				var type="";
				for (i=1;i<=16;i++) total += parseInt(action[i]);
				switch (parseInt(action.tileType)) {
					case 0: info = "Bog";break;
					case 10: info = "Grassland";break;
					case 11: info = "Lake";break;
					case 20: info = "Woods";break;
					case 30: info = "Hills";break;
					case 40: info = "Mountain";break;
					case 50: info = "Plain";break;
					case 51: 
						if (action.targetCityName == null && !action.misted) info = "Barb Camp";
							else info = action.targetName;
						break;
					case 53: info = "Misted City";break;
				}
				switch (parseInt(action.action)) {
					case 1: type = "Transport";break;
					case 2: type = "Reinforce";break;
					case 3: type = "Scout";break;
					case 4: type = "Attack";break;
					case 5: type = "Reassign";break;
				} 
    			msg += '<TR><TD>'+logcity+'</td><TD>'+coordLink(parseInt(action.targetX),parseInt(action.targetY))+'</td><TD>'+info+'</td><TD>'+action.targetCityName+'</td><TD>'+addCommas(total)+'</td><TD><INPUT type=submit class=pbButton id="dbDoAction' + k + '" value='+ type +' style="color:red;"></td>';
    		}
    		document.getElementById('MarchesInfo').innerHTML = msg;
			for (k=0;k<MarchOptions.Queue.length;k++) document.getElementById('dbDoAction' + k).addEventListener('click', function(){Tabs.March.doMarch(MarchOptions.Queue[this.id.substr(10)]);}, false);
			document.getElementById('HideMarches').addEventListener ('click', function(){t.clearMarches();},false);
		} else document.getElementById('ShowMarches').innerHTML = "";

	},

	showSacrifice: function(){
		var t = Dashboard;
		var now = unixTime();
		var NoSacrifice = true;
		for (var i=0;i<Seed.cities.length;i++) if (Seed.queue_sacr["city"+Seed.cities[i][0]][0]!=undefined) NoSacrifice = false;
    	if (NoSacrifice) {
    		document.getElementById('SacrificePlaceholder').innerHTML = "";
    		return;
    	}
		var msg = '<DIV class="pbStat">Sacifice</div><TABLE id=pbRPStats 50% class=pbTab>';
		for (var i=0;i<Seed.cities.length;i++){
			var cityID = Seed.cities[i][0];
			if (Seed.queue_sacr["city"+cityID][0]!=undefined) msg+='<TR><TD width=150px>'+Seed.cities[i][1]+' (1)</td><TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+Seed.queue_sacr["city"+cityID][0].unitType +'_30_s34.jpg?6545></td><TD width=75px>'+Seed.queue_sacr["city"+cityID][0].quantity+'</td><TD width=50px>'+timestr(Seed.queue_sacr["city"+cityID][0].eta-now)+' ('+timestr(Seed.queue_sacr["city"+cityID][0].eta-Seed.queue_sacr["city"+cityID][0].start)+')</td></tr>';
			if (Seed.queue_sacr["city"+cityID][1]!=undefined) msg+='<TR><TD width=150px>'+Seed.cities[i][1]+' (2)</td><TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+Seed.queue_sacr["city"+cityID][1].unitType +'_30_s34.jpg?6545></td><TD width=75px>'+Seed.queue_sacr["city"+cityID][1].quantity+'</td><TD width=50px>'+timestr(Seed.queue_sacr["city"+cityID][1].eta-now)+' ('+timestr(Seed.queue_sacr["city"+cityID][1].eta-Seed.queue_sacr["city"+cityID][1].start)+')</td></tr>';
		}
		msg += '</table>';
		document.getElementById('SacrificePlaceholder').innerHTML = msg;
	},
	
	clearMarches: function (){
    	var t = Dashboard;
		if (!t.showMarchesInfo) {
			t.showMarchesInfo=true;
			t.ShowMarches();
		} else {
				if (document.getElementById('MarchesInfo')) document.getElementById('MarchesInfo').innerHTML ="";
				document.getElementById('HideMarches').value = "Show";
				t.showMarchesInfo=false;
			}
    },

    ShowRP: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat">Rallypoints</div><TABLE id=pbRPStats width=100% class=pbTab><TR>';
		for(b=0; b<Seed.cities.length;b++) {
    		slots = CheckCityMarches(b);
    		rallypointlevel = getRallypoint(Seed.cities[b][0]);
			msg += '<TD>' + unsafeWindow.roman[b] + ': (' + slots + '/' + rallypointlevel +')</td>';
			if ((b+1)%4==0) msg+='</tr><TR>';
		}
		document.getElementById('ShowRP').innerHTML = msg;
    },

    ShowTrPresets: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat"><INPUT id=pbTRHelp type=submit class=pbButton value="HELP">&nbsp; &nbsp; Throne Preset Switcher</div><TABLE id=pbThroneTr width=100% class=pbTab><TR>';
    	for (i=1;i<=8;i++) {		
    			var total = 0;
    			var active =0;
    			var what="";
    			for (j=1;j<Tabs.Throne.EquipType.length;j++) {
    				what = Tabs.Throne.EquipType[j];
    				id = ThroneOptions.Presets[i][what.toLowerCase()];
    				if (what == "Chair") what = "Throne";
     				if (what == "Windows") what = "Window";
     				if (unsafeWindow.kocThroneItems[id] != undefined && unsafeWindow.kocThroneItems[id].isEquipped) active++;
     				if (id > 0) total++;
    			}
    			if (active == total) msg+= '<TD align="center"><B>'+active+'/'+total+'</b></td>';
    				else msg+= '<TD align="center">'+active+'/'+total+'</td>';
    			var stats = renderLocalPresetStats(i);
    			msg+= '<TD><a class=hasTooltip><INPUT type=submit class=pbButton id="Preset_' + i + '" value="'+ThroneOptions.PresetName[i]+'"><SPAN>'+stats+'</span></a></td>';
    			if (i%4==0) msg+='</tr><TR>';
    	}
    	msg += '</tr></table>';
    	msg += '<TABLE class=pbTab><TR><TD style="width:100px">Kabam presets:</td>';
    	for (var i=1;i<=Seed.throne.slotNum;i++) {
    		msg+='<TD style="width:30px"><a class=hasTooltip><INPUT type=submit class=pbButton id="KabamPreset_' + i + '" value="'+i+'"><SPAN id="KabamPresetHover'+i+'"></span></a></td>';
    	}
    	msg += '</tr></table>';
    	document.getElementById('ShowTrPresets').innerHTML = msg;
    	//for (var i=1;i<=Seed.throne.slotNum;i++) 
    	document.getElementById('pbTRHelp').addEventListener('click', function () {t.helpPop();});
		for (i=1;i<=8;i++) document.getElementById('Preset_' + i).addEventListener ('click', function(){Tabs.Throne.EquipPreset(this.id.substr(7))},false);
		
		for (i=1;i<=Seed.throne.slotNum;i++) {
			if (document.getElementById('KabamPreset_'+i)) document.getElementById('KabamPreset_' + i).addEventListener ('click', function(){Tabs.Throne.EquipKabamPreset(this.id.substr(12))},false);
			if (i==Seed.throne.activeSlot && document.getElementById('KabamPreset_'+i)) document.getElementById('KabamPreset_'+i).setAttribute("class", "pbButton_selected");
			if (i==Seed.throne.activeSlot && document.getElementById('KabamPreset_Chat_'+i)) document.getElementById('KabamPreset_Chat_'+i).setAttribute("class", "pbButton_selected");
			renderKabamPresetStats(i); 
		}
    },
	ShowTrPresetsMini: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat">TR Switcher &nbsp; <INPUT id=pbTRHelp type=submit class=pbButton value="?"></div><TABLE id=pbThroneTr width=100% class=pbTab>';
    	for (i=1;i<=6;i++) {
    			msg+= '<TR><TD><INPUT type=submit class=pbButton id="Preset_' + i + '" value="'+ThroneOptions.PresetName[i]+'"></td>';
    			var total = 0;
    			var active =0;
    			var what="";
    			for (j=1;j<Tabs.Throne.EquipType.length;j++) {
    				what = Tabs.Throne.EquipType[j];
    				id = ThroneOptions.Presets[i][what.toLowerCase()];
    				if (what == "Chair") what = "Throne";
     				if (what == "Windows") what = "Window";
     				if (unsafeWindow.kocThroneItems[id] != undefined && unsafeWindow.kocThroneItems[id].isEquipped) active++;
     				if (id > 0) total++;
    			}
    			if (active == total) msg+= '<TD align="center"><B>'+active+'/'+total+'</b></td></tr>';
    				else msg+= '<TD align="center">'+active+'/'+total+'</td></tr>';
    	}
    	msg += '</table>'
    	document.getElementById('ShowTrPresets').innerHTML = msg;
    	document.getElementById('pbTRHelp').addEventListener('click', function () {t.helpPop();});
		for (i=1;i<=6;i++) document.getElementById('Preset_' + i).addEventListener ('click', function(){Tabs.Throne.EquipPreset(this.id.substr(7))},false);
    },
	
	helpPop: function () {
        var helpText = '<DIV style="height:462px;max-height=462px"><BR><B>This DOES work.</b><BR><BR>It just might not do what you think it does.<BR><BR>These are LOCAL presets, it DOES NOT switch the game presets.<BR><BR><U><B>To use this feature...</b></u><BR><BR>1. Go to your AIO and select the Throne tab.<BR><BR>2. Select the Preset subtab.<BR><BR>3. In here you will see local presets that you can rename to whatever you want, eg \'Training\' or \'Range\'.<BR><BR>4. Once named, switch to the \'Compare\' subtab. These are all your cards.<BR><BR>5. Click on any of the titles of the cards. This opens a popup window where you can equip, add to preset, add to update or enhance queue.<BR><BR>6. Once you add it to a preset, go back to the \'Preset\' subtab.<BR><BR>7. You should now see your card in the preset you added it to.<BR><BR>8. Refresh <BR><BR> 9.Click on the \'Quick TR Switcher\' button on the dashboard for those cards to be equipped automatically.</div>';
        var pop = new pbPopup('giftHelp', 0, 0, 425, 485, true);
        pop.centerMe(mainPop.getMainDiv());
        pop.getMainDiv().innerHTML = helpText;
        pop.getTopDiv().innerHTML = '<CENTER><B>TR Switcher Help</b></center>';
        pop.show(true);
	},

	ShowAutoTrain: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat">Auto Train</div>';
		var now = unixTime();
		if (!TrainOptions.Running) msg+="Auto Train is OFF";
			else {
				if (Tabs.AutoTrain.trainTime > now) msg += "Doing Train cycle (Set Preset/Train Troops/Reset TR Items) for: " + timestr(Tabs.AutoTrain.trainTime - now);
					else if (Tabs.AutoTrain.nextround > now) msg += "Next Auto Train cycle in: " + timestr(Tabs.AutoTrain.nextround - now);
		}
 		document.getElementById('ShowAutoTrain').innerHTML = msg;
    },

    ShowTowerAlerts: function (){
    	var t = Dashboard;
    	var NoAttack = true;
    	for (k in Seed.queue_atkinc) if (Seed.queue_atkinc[k].marchType == 3 || Seed.queue_atkinc[k].marchType ==4) NoAttack = false;
    	if (NoAttack) {
    		document.getElementById('TowerAlertPlaceholder').innerHTML = "";
    		return;
    	}
    	document.getElementById('TowerAlertPlaceholder').innerHTML = '<BR><DIV class="pbStatRed">Tower Alerts</div><DIV id=ShowTowerAlerts></div>'; //style="height: 100px; overflow: auto">
    	var msg = '';
    	var action = '';
    	var arrivalTime = 0;

    	for(k in Seed.queue_atkinc) {
    		var now = unixTime();
    		var counter = 0;

    		if (Seed.queue_atkinc[k].fromPlayerId != unsafeWindow.tvuid && Seed.queue_atkinc[k].arrivalTime > now) {
				for (postcity in Seed.cities) if (Seed.cities[postcity][0] == Seed.queue_atkinc[k].toCityId) cityName = Seed.cities[postcity][1];
				if (Seed.queue_atkinc[k].marchType == 3) action = "Scout";
				if (Seed.queue_atkinc[k].marchType == 4) action = "Attack";
				arrivalTime = Seed.queue_atkinc[k].arrivalTime - now;
				msg += cityName + ': ' + action + ' -- ETA: ' + timestr(arrivalTime);
				msg +='<BR><TABLE class=pbTab><TR>';
				for (i=1;i<=16;i++){
					if (Seed.queue_atkinc[k]["unts"] == undefined) {
						msg +='<TR><TD>???</td></tr>'; 
					} else if (parseInt(Seed.queue_atkinc[k]["unts"]["u"+i]) > 0) {
						if (counter%4==0) msg+='</tr><TR>';
						counter++;
						msg+='<TD width=30px><img src=http://www352.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+i+'_30_s34.jpg?6545></td><TD width=80px>' + parseInt(Seed.queue_atkinc[k]["unts"]["u"+i]) + '</td>';
					}
				}
				msg+='</tr></table>';
			}

    	}
    	document.getElementById('ShowTowerAlerts').innerHTML = msg;
    },

    RPM: function (){
    	var t = Dashboard;
    	var now=unixTime();
        var time = 0;
        var calc = 0
        time = now - RPMtime;   
        calc =(RPM/time)*60;
        calc = Math.round(calc);
        if (time <30) calc = "...";
        document.getElementById('dbHeader').innerHTML = "Requests send per minute: " + calc + ' (<SPAN id=MouseMove></span>)'; 
    },

    CityStatus: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat">City Defend Status</div><TABLE id=pbRPStats width=100% class=pbTab><TR>';
    	for(b=0; b<Cities.numCities; b++) msg+= '<TD><INPUT type=submit id="cityDEF_' + Seed.cities[b][0] + '" value="'+unsafeWindow.roman[b]+'"></td>';
    	document.getElementById('CityStatus').innerHTML = msg;
    	for(b=0; b<Cities.numCities; b++) {
    		if (parseInt(Seed.citystats["city" + Seed.cities[b][0]].gate) == 0) document.getElementById('cityDEF_' + Seed.cities[b][0]).style.backgroundColor  = "green";
    			else document.getElementById('cityDEF_' + Seed.cities[b][0]).style.backgroundColor  = "red";
    		document.getElementById('cityDEF_' + Seed.cities[b][0]).style.color  = "white";
    		document.getElementById('cityDEF_' + Seed.cities[b][0]).addEventListener ('click', function(){
	    		var city = this.id.substr(8);
	    		if (parseInt(Seed.citystats["city" + city].gate) == 0) t.ChangeDefMode(city,1);
	    		if (parseInt(Seed.citystats["city" + city].gate) == 1) t.ChangeDefMode(city,0);
      		},false);
    	}    	
    },

    ChangeDefMode : function (cityId, state){
    	var t = Dashboard;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.cid = cityId;
        params.state = state;
        
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/gate.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (rslt) {
                if (rslt.ok) {
                    Seed.citystats["city" + cityId].gate = state;
                    if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                }
            },
            onFailure: function () {
            }
        })
  	},

  	ShowLog: function (){
  		var t = Dashboard;
  		var msg = '<DIV class="pbStat">Action Log</div>';
  		var amount = parseInt(Tabs.Options.last250.length)-1;
  		for (i=amount;i>(amount-5);i--) if (Tabs.Options.last250[i] != undefined) msg+= Tabs.Options.last250[i].ts + ': ' + Tabs.Options.last250[i].msg + '<BR>';
  		document.getElementById('ShowLog').innerHTML = msg;
    
    },

    ShowTroops: function (){
    	var t = Dashboard;
    	var msg = '<DIV class="pbStat">Troops</div>';
    	msg+= '<SPAN id=dbCityCel></span>&nbsp&nbsp&nbsp<INPUT type=submit class=pbButton id="HideTroops" value="Hide"><BR><DIV id=dbCityInfo></div>';
    	document.getElementById('ShowTroops').innerHTML = msg;  	
    	t.tcp = new CdispCityPicker ('dbCityCelBut', document.getElementById('dbCityCel'), true, t.PaintTroops);
    	document.getElementById('HideTroops').addEventListener ('click', function(){document.getElementById('dbCityInfo').innerHTML = "";t.tcp = new CdispCityPicker ('dbCityCelBut', document.getElementById('dbCityCel'), true, t.PaintTroops)},false);	
    },

    PaintTroops: function (){
    	var t = Dashboard;
    	var info ='<TABLE id=pbRPStats width=100% class=pbTab><TR>';
    	for (l in Seed.units['city' + t.tcp.city.id]) {
    		info+= '<TD style="width: 30px;"><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ l.substr(3) +'_30_s34.jpg?6545></td><TD style="vertical-align: middle;">' + addCommas(Seed.units['city' + t.tcp.city.id][l]) +'</td>';
    		if (l.substr(3)%4==0) info+='</tr><TR>';
    	}
    	document.getElementById('dbCityInfo').innerHTML = info;
    },

    show: function (){},
    
    hide : function (){}
}

    

/*********************************** Options Tab ***********************************/
Tabs.Options = {
  tabOrder: 699,
  myDiv : null,
  curTabBut : null,
  curTabName : null,
  maxEntries: 300,
  last250 : [],
  state : null,
  Data: {Options: {},GlobalOptions: {},Colors: {},ChatIcons: {},Build1: {},Build2: {},Build3: {},Build4: {},Build5: {},Build6: {},Build7: {},Build8: {},ThroneOptions: {},CrestOptions: {},TrainOptions: {},ReassignRoutes: {},BuildOptions: {},TransportOptions: {},TransportState: {},RaidOptions: {},DFOptions: {},ApothecaryOptions: {},FarmOptions: {},TradeOptions: {},MarchOptions: {},CraftOptions: {},AtkOptions: {},mercOptions : {},DFOptions: {}},
  
  init : function (div){
    var t = Tabs.Options;

    t.cont = div;
    var main = '<TABLE align=center class=pbTab width=85%><TR><TD><INPUT class=pbButton ID=pbOptions_Options type=submit value="Options"></td>';    
	main +='<TD><INPUT class=pbButton ID=pbOptions_Layout type=submit value="Layout"></td>';
	main +='<TD><INPUT class=pbButton ID=pbOptions_Log type=submit value="Log"></td>';
	main +='<TD><INPUT class=pbButton ID=pbOptions_Dashboard type=submit value="Dashboard"></td>';
	main +='<TD><INPUT class=pbButton ID=pbOptions_Spam type=submit value="Spam"></td>';
	main +='<TD><INPUT class=pbButton ID=pbOptions_Export type=submit value="Export"></td></tr></table><HR class=ptThin>';
    main +='<DIV id=pbOptOutput style="margin-top:10px; height:650px; overflow:auto;"></div>';
    t.cont.innerHTML = main;
    t.Overv = document.getElementById('pbOptOutput');
    
    document.getElementById('pbOptions_Options').addEventListener('click', e_butSubtab, false);
    document.getElementById('pbOptions_Layout').addEventListener('click', e_butSubtab, false);
    document.getElementById('pbOptions_Log').addEventListener('click', e_butSubtab, false);
    document.getElementById('pbOptions_Dashboard').addEventListener('click', e_butSubtab, false);
    document.getElementById('pbOptions_Spam').addEventListener('click', e_butSubtab, false);
    document.getElementById('pbOptions_Export').addEventListener('click', e_butSubtab, false);
	

	window.addEventListener('unload', t.onUnload, false);  
	var a = JSON2.parse(GM_getValue ('log_'+getServerId(), '[]'));
    if (matTypeof(a) == 'array') t.last250 = a;
 
    changeSubtab (document.getElementById('pbOptions_'+Options.curOptTab));
    
    function e_butSubtab (evt){            
      changeSubtab (evt.target);   
    }

    function changeSubtab (but){
      if (but == t.curTabBut)
        return;
      if (t.curTabBut){
        t.curTabBut.className='pbButton'; 
        t.curTabBut.disabled=false;
      }
      t.curTabBut = but;
      but.className='pbButton_selected'; 
      but.disabled=true;
      t.curTabName = but.id.substr(10);
	  Options.curOptTab = t.curTabName;
      t.show();
    }
  },

  Options: function(){
  	var t= Tabs.Options;
	 try {      
      m = '<DIVstyle="height:650px; max-height:650px; overflow-y:auto"><TABLE class=pbTab width=100% class=pbTab cellspacing=0 cellpadding=0>\
        <TR><TD colspan=2><B>'+translate("AIO Script Config:")+'</b></td></tr>\
        <TR><TD width=30px>&nbsp;&nbsp;&nbsp;-</td><TD style="max-width:150px;word-break:break-all;">Global Rallypoint setting (Crest/DF/Attack/Transport/Reassign) - Keep <INPUT id=pbRPClip type=text size=1 maxlength=1> rallypoint slots free.</td></tr>\
        <TR><TD><INPUT id=pballowWinMove type=checkbox /></td><TD>'+translate("Enable window drag (move window by dragging top bar with mouse)")+'</td></tr>\
        <TR><TD><INPUT id=pbTrackWinOpen type=checkbox /></td><TD>'+translate("Remember window open state on refresh")+'</td></tr>\
        <TR><TD><INPUT id=pbHideOnGoto type=checkbox /></td><TD>'+translate("Hide window when clicking on map coordinates")+'</td></tr>\
        <TR><TD><INPUT id=pbWideOpt type=checkbox '+ (GlobalOptions.pbWideScreen?'CHECKED ':'') +'/></td><TD>'+translate("Enable widescreen style:")+' '+ htmlSelector({wide:'Widescreen', ultra:'Ultra'},GlobalOptions.pbWideScreenStyle,'id=selectScreenMode') +' '+translate("(all domains, requires refresh)")+'</td></tr>\
        <TR><TD><INPUT id=pbsendmeaway type=checkbox '+ (GlobalOptions.pbNoMoreKabam?'CHECKED ':'')+'/></td><TD>'+translate("Send me away from Kabam!")+'</td></tr>\
        <TR><TD>&nbsp;&nbsp;&nbsp;-</td><TD>'+translate("Change window transparency between \"0.7 - 2\" ")+'&nbsp <INPUT id=pbtogOpacity type=text size=3 /> <span style="color:#800; font-weight:bold"><sup>'+translate("*Requires Refresh")+'</sup></span></td></tr>\
        <TR><TD colspan=2><BR><B>'+translate("KofC Features:")+'</b></td></tr>\
        <TR><TD><INPUT id=pbFairie type=checkbox /></td><TD>'+translate("Disable annoying Faire and Court popups")+'</td></tr>\
        <TR><TD><INPUT id=pbWatchEnable type=checkbox '+ (GlobalOptions.pbWatchdog?'CHECKED ':'') +'/></td><TD>'+translate("Refresh if KOC not loaded within 1 minute (all domains)")+'</td></tr>\
        <TR><TD><INPUT id=pbEveryEnable type=checkbox /></td><TD>'+translate("Refresh KOC every")+' <INPUT id=pbeverymins type=text size=2 maxlength=3> '+translate("minutes")+'</td></tr>\
        <TR><TD><INPUT id=pbChatREnable type=checkbox /></td><TD>'+translate("Put chat on right (requires wide screen)")+'</td></tr>\
        <TR><TD><INPUT id=pbWMapEnable type=checkbox /></td><TD>'+translate("Use WideMap (requires wide screen)")+'</td></tr>\
        <TR><TD><INPUT id=pbGoldEnable type=checkbox /></td><TD>'+translate("Auto collect gold when happiness reaches")+' <INPUT id=pbgoldLimit type=text size=2 maxlength=3 \>%</td></tr>\
        <TR><TD><INPUT id=pbFoodToggle type=checkbox /></td><TD>'+translate("Enable Food Alert (on less than 6 Hours of food. Checked every hour)")+'</td></tr>\
        <TR><TD><INPUT id=togAllowMulti type=checkbox /></td><TD>Disable \"You have Koc open in a newer window\" pop-up:<br/><b>(Use at own risk, you will be logged by kabam for this method)</b></td></tr>\
        <TR><TD><INPUT id=pbSummonToggle type=checkbox /></td><TD>'+translate("Hide Summoning Circle (Refresh needed)")+'</td></tr>\
        <TR><TD colspan=2><BR><B>'+translate("Extra Features")+':</b></td></tr>\
        <TR><TD><INPUT id=HelReq type=checkbox /></td><TD width=100px>'+translate("Help alliance build/research posts")+'</td><TD  width=30px><INPUT id=DelReq type=checkbox /></td><TD>'+translate("Hide alliance requests in chat")+'</td></tr>\
        <TR><TD><INPUT id=PubReq type=checkbox '+ (GlobalOptions.autoPublishGamePopups?'CHECKED ':'') +'/></td><TD>'+translate("Auto HIDE Facebook posts")+'</td><TD><INPUT id=MapExtra type=checkbox /></td><TD>'+translate("Show Player & Might in map")+'.</td></tr>\
        <TR><TD><INPUT id=deletetoggle type=checkbox /></td><TD> '+translate("Auto delete barb/transport reports from you")+'</td><TD><INPUT id=deletes0toggle type=checkbox /></td><TD> '+translate("Auto delete transport reports to you")+'</td></tr>\
        <TR><TD><INPUT id=deletes1toggle type=checkbox /></td><TD> '+translate("Auto delete wild reports")+'</td><TD><INPUT id=deletes2toggle type=checkbox /></td><TD> '+translate("Auto delete crest reports regardless of target type")+'</td></tr>\
        <TR><TD><INPUT id=deletes3toggle type=checkbox /></td><TD> '+translate("Auto delete DF reports")+'</td><TD><INPUT id=MAgicBOx type=checkbox /></td><TD> '+translate("Kill merlins magic box's on startup")+'</td></tr>\
        <TR><TD><INPUT id=ptEnableWisperAlert type=checkbox /></td><TD>Enable sound alert on whisper</td><TD><INPUT id=ptEnableTowerAlert type=checkbox /></td><TD>Enable sound alert on tower alert in chat</td></tr>\
        </table><BR><TABLE class=pbTab><TR><TD rowspan=2><select multiple size="4" id="ExcludeMembers" style="width:200px"></td><TD></select><SPAN><INPUT type=submit id="RemoveFilter" value="Remove"></td></tr>\
        <TR><TD>Attack reports from the user(s) in this list will <B>automatically</b> be deleted! Add users to this list with the \"Player Search Tab\".</td></tr></table>\
        <HR>'+strButton20(translate('Reset ALL Options'), 'id=ResetALLOPT') + '</div>';
     t.Overv.innerHTML = m;
     //
      document.getElementById('selectScreenMode').addEventListener ('change', function(){
              GlobalOptions.pbWideScreenStyle = document.getElementById('selectScreenMode').value;
              GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));
      },false);    
      document.getElementById('PubReq').addEventListener ('change', function(){
              GlobalOptions.autoPublishGamePopups = document.getElementById('PubReq').checked;
            GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));
      },false);    
      document.getElementById('pbsendmeaway').addEventListener ('click', function(){
            GlobalOptions.pbNoMoreKabam = document.getElementById('pbsendmeaway').checked;
            GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));
      },false);    
      document.getElementById('RemoveFilter').addEventListener ('click', function(){
      	if (document.getElementById('ExcludeMembers').value!="") Options.PlayerFilter.splice(document.getElementById('ExcludeMembers').value,1);
      	t.PaintFilterList();
      },false);

      document.getElementById('ResetALLOPT').addEventListener ('click', function(){
              var serverID = getServerId();
              RemoveList = (GM_listValues());
              for (i=0;i<RemoveList.length;i++){
                  GM_deleteValue(RemoveList[i]);
              }
              ResetAll=true;
              reloadKOC();
      },false);

      document.getElementById('pbWatchEnable').addEventListener ('change', t.e_watchChanged, false);
      document.getElementById('pbWideOpt').addEventListener ('change', t.e_wideChanged, false);
      t.changeOpt ('pbtogOpacity', 'Opacity');
      t.changeOpt ('pbRPClip', 'RPClip');
      t.togOpt ('pballowWinMove', 'pbWinDrag', mainPop.setEnableDrag);
      t.togOpt ('pbTrackWinOpen', 'pbTrackOpen');
      t.togOpt ('pbHideOnGoto', 'hideOnGoto');
      t.togOpt ('pbFairie', 'pbKillFairie', FairieKiller.setEnable);
      t.togOpt ('pbGoldEnable', 'pbGoldEnable', CollectGold.setEnable);
      t.changeOpt ('pbgoldLimit', 'pbGoldHappy');
      t.togOpt ('pbFoodToggle', 'pbFoodAlert');
     t.togOpt ('togAllowMulti', 'allowMultiBroswer', bypassMulti.setEnable, bypassMulti.isAvailable);
 
      t.togOpt ('pbSummonToggle', 'pbSummonToggle');
      t.changeOpt ('pbeverymins', 'pbEveryMins' , RefreshEvery.setTimer);
      t.togOpt ('pbEveryEnable', 'pbEveryEnable', RefreshEvery.setEnable);
      t.togOpt ('pbChatREnable', 'pbChatOnRight', WideScreen.setChatOnRight);
      t.togOpt ('pbWMapEnable', 'pbWideMap', WideScreen.useWideMap);
      t.togOpt ('pbEveryEnable', 'pbEveryEnable', RefreshEvery.setEnable);
      t.togOpt ('HelReq', 'HelpRequest');
      t.togOpt ('DelReq', 'DeleteRequest');
      t.togOpt ('MapExtra', 'MapShowExtra');
      t.togOpt ('deletetoggle', 'DeleteMsg');
      t.togOpt ('deletes0toggle', 'DeleteMsgs0');
      t.togOpt ('deletes1toggle', 'DeleteMsgs1');
      t.togOpt ('deletes2toggle', 'DeleteMsgs2'); 
      t.togOpt ('deletes3toggle', 'DeleteMsgs3');
      t.togOpt ('MAgicBOx', 'KMagicBox');
      t.togOpt ('ptEnableWisperAlert', 'enableWhisperAlert');
      t.togOpt ('ptEnableTowerAlert', 'enableTowerAlert'); 
      
      t.PaintFilterList();  
    } catch (e) {}  		
  },

  PaintFilterList:function(){
  	 document.getElementById('ExcludeMembers').options.length=0; 
   	  for (var i=0;i<Options.PlayerFilter.length;i++){
	        if (Options.PlayerFilter[i]["uid"] !=undefined){
	            var o = document.createElement("option");
	            o.text = Options.PlayerFilter[i]["name"];
	            o.value = i;
	            document.getElementById("ExcludeMembers").options.add(o);
	        }
	  }          
  },

  spam: function(){
  	var t=Tabs.Options;
  	var m = '<DIV class=pbStat>Advertise</div><TABLE class=pbTab width=100% height=0% ><TR align="center">';
  	m+='<TD><INPUT class="buttonDash_'+ (Options.spamconfig.aspam?'ON':'OFF') +'" id=pbSpamEnable type=submit value="'+translate("Spam")+' = '+ (Options.spamconfig.aspam?'ON':'OFF')+'"></td>';
       if (Options.spamconfig.spamstate == 'a') m += '<TD><INPUT id=pbSpamState type=submit class=pbButton value="Send To Alliance"></td>';
        else m += '<TD><INPUT id=pbSpamState type=submit class=pbButton value="Send To  Global "></td>';
        m += '</tr></table></div>';
       m += '<DIV class=pbStat>Settings</div><TABLE class=pbTab>';
        m += '<tr><td>Automatically post every <INPUT id=pbSpamMin type=text size=2 maxlength=3 value="'+ Options.spamconfig.spammins +'"  \> minutes</td></tr><BR>\
              <tr><TD><TABLE cellpadding=0 cellspacing=0>\
              <TD align=left>Your spam: &nbsp; </td><TD><INPUT id=pbSpamAd type=text size=60 maxlength=500 value="'+ Options.spamconfig.spamvert +'" \></td></tr>\
              </table><BR>';
    
    t.Overv.innerHTML = m;

    document.getElementById('pbSpamEnable').addEventListener ('click', function(){t.toggleon(this);}, false);
    document.getElementById('pbSpamAd').addEventListener ('change', t.e_spamOptChanged, false);
    document.getElementById('pbSpamMin').addEventListener ('change', t.e_spamOptChanged, false);
    document.getElementById('pbSpamState').addEventListener ('click', function(){t.togglespam(this);}, false);
  },

  Paintlog: function(){
  	var t=Tabs.Options;
  	t.Overv.innerHTML = '<DIV class=pbStat>ACTION LOG - VERSION: '+ Version+'</div><DIV style="height:600px;max-height:600px;max-width:500px:overflow-y:auto;overflow-x:auto">\
      <TABLE cellpadding=0 cellspacing=0 id=pbactionlog class=pbTabLined><TR><TD></td><TD width=95%></td></table></div>';
    t.logTab = document.getElementById('pbactionlog');  
    t.state = 1;
    for (var i=0; i<t.last250.length; i++) t._addTab (t.last250[i].msg, t.last250[i].ts);
  },

   _addTab : function (msg, ts){
    var t = Tabs.Options;
    if (t.state != 1) return;
    if (t.logTab.rows.length >= t.maxEntries) t.logTab.deleteRow(t.maxEntries-1);
    var row = t.logTab.insertRow(0);
    row.vAlign = 'top';
    row.insertCell(0).innerHTML = ts;
    row.insertCell(1).innerHTML = msg;
  },
  
  log : function (msg){
    var t = Tabs.Options;
    var ts = new Date().toTimeString().substring (0,8);
    t._addTab (msg, ts);
    while (t.last250.length >= 250) t.last250.shift();
    t.last250.push ({msg:msg, ts:ts});
  },

  Layout :function (){
    var t = Tabs.Options;  
    saveColors();
    try {      
      m= '<TABLE class=ptTab>';
	  m+='<TR><TD colspan=2><U><B>Chat Layout:</b></u></td></tr>';
	  m+='<TR><TD><INPUT id=togChatStuff type=checkbox /></td><TD>Enable Chat Enable Chat enhancements (clickable coords, click on icon to whisper, colors).</td></tr>';
      m+='<TR><TD><INPUT id=togChatGlobal type=checkbox /></td><TD>Enable Global chat background color.</td></tr>';
	  m+='<TR><TD><INPUT id=togChatWhisper type=checkbox /></td><TD>Enable Whisper in Color Font.</td></tr>';
	  m+='<TR><TD><INPUT id=togChatBold type=checkbox /></td><TD>Enable Chat in Bold Font.</td></tr>';
	  m+='<TR><TD><INPUT id=togChatAttack type=checkbox /></td><TD>Enable background color on tower alert.</td></tr>';
	  m+='<TR><TD><INPUT id=togChatLead type=checkbox /></td><TD>Enable background for alliance Leaders.<SPAN class=boldRed>&nbsp;(NEW)</span></td></tr></table>';

	  m+='<TABLE class=ptTab><BR><TR><TD colspan=2><U><B>Colors: &nbsp;(Refresh for effect)</b></u></td></tr>';
      m+='<TR><TD>Chat Color - Global: </td><TD><INPUT id=togGlobal type=text size=7 maxlength=7 value="'+Colors.ChatGlobal+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatGlobal+'" width=30px>&nbsp;</td></tr>';
	  m+='<TR><TD>Chat Color - Alliance: </td><TD><INPUT id=togAll type=text size=7 maxlength=7 value="'+Colors.ChatAll+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatAll+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>Chat Color - Tower Alert: </td><TD><INPUT id=togChatAtt type=text size=7 maxlength=7 value="'+Colors.ChatAtt+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatAtt+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>Chat Color - Whisper Alert: </td><TD><INPUT id=togWhisper type=text size=7 maxlength=7 value="'+Colors.ChatWhisper+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatWhisper+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>Chat Color - Chancy: </td><TD><INPUT id=togChatC type=text size=7 maxlength=7 value="'+Colors.ChatChancy+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatChancy+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>Chat Color - Vice-C: </td><TD><INPUT id=togChatVC type=text size=7 maxlength=7 value="'+Colors.ChatVC+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatVC+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>Chat Color - Officers: </td><TD><INPUT id=togChatLeaders type=text size=7 maxlength=7 value="'+Colors.ChatLeaders+'"></td>&nbsp;<TD style="background-color:'+Colors.ChatLeaders+'" width=30px>&nbsp;</td></tr>';
	  
	  
      m+='<TR><TD>General - Dark Row: </td><TD><INPUT id=togDarkRow type=text size=7 maxlength=7 value="'+Colors.DarkRow+'"></td>&nbsp;<TD style="background-color:'+Colors.DarkRow+'" width=30px>&nbsp;</td></tr>';
      m+='<TR><TD>General - Button Selected: </td><TD><INPUT id=togButClick type=text size=7 maxlength=7 value="'+Colors.ButtonSelected+'"></td>&nbsp;<TD style="background-color:'+Colors.ButtonSelected+'" width=30px>&nbsp;</td></tr>';
     
      m+='<TR><TD>Overview - Dark Rows:</td><TD><INPUT id=togOverDarkRow type=text size=7 maxlength=7 value="'+Colors.OverviewDarkRow+'"></td>&nbsp;<TD style="background-color:'+Colors.OverviewDarkRow+'" width=30px>&nbsp;</td></tr>';
	  m+='<TR><TD>Transparency:&nbsp;&nbsp;<span style="color:#800;"><sup>(0.7 - 2)</sup></span></td><TD><INPUT id=togOpacity type=text size=3 maxlength=3 value="'+Colors.Opacity+'"/></td><TD></tr>';
	  
      m+='</table><BR><BR><DIV>HTML colors:&nbsp;&nbsp;&nbsp;';
      m+='<a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;';
      m+='<a href="http://www.w3schools.com/html/html_colors.asp" target="_blank">Colors</a>';
      m+='</table><BR><BR><HR>To apply colors you need to REFRESH!<BR>';
      m+= strButton20('Reset Colors', 'id=ResetALL');
      t.Overv.innerHTML = m;
            
      t.togOpt ('togChatStuff', 'chatEnhance', ChatStuff.setEnable, ChatStuff.isAvailable);
      t.togOpt ('togChatGlobal', 'chatglobal');
      t.togOpt ('togChatWhisper', 'chatwhisper');	
      t.togOpt ('togChatBold', 'chatbold');
      t.togOpt ('togChatAttack', 'chatAttack');
      t.togOpt ('togChatLead', 'chatLeaders');
      
      document.getElementById('togGlobal').addEventListener('change', function(){Colors.ChatGlobal = document.getElementById('togGlobal').value;t.Layout()}, false);
      document.getElementById('togChatLeaders').addEventListener('change', function(){Colors.ChatLeaders = document.getElementById('togChatLeaders').value;t.Layout()}, false);
      document.getElementById('togChatC').addEventListener('change', function(){Colors.ChatChancy = document.getElementById('togChatC').value;t.Layout()}, false);
      document.getElementById('togChatVC').addEventListener('change', function(){Colors.ChatVC = document.getElementById('togChatVC').value;t.Layout()}, false);
      document.getElementById('togDarkRow').addEventListener('change', function(){Colors.DarkRow = document.getElementById('togDarkRow').value;t.Layout()}, false);
      document.getElementById('togButClick').addEventListener('change', function(){Colors.ButtonSelected = document.getElementById('togButClick').value;t.Layout()}, false);
      document.getElementById('togOverDarkRow').addEventListener('change', function(){Colors.OverviewDarkRow = document.getElementById('togOverDarkRow').value;t.Layout()}, false);
      document.getElementById('togAll').addEventListener('change', function(){Colors.ChatAll = document.getElementById('togAll').value;t.Layout()}, false);
      document.getElementById('togChatAtt').addEventListener('change', function(){Colors.ChatAtt = document.getElementById('togChatAtt').value;t.Layout()}, false);
      document.getElementById('togWhisper').addEventListener('change', function(){Colors.ChatWhisper = document.getElementById('togWhisper').value;t.Layout()}, false);
      document.getElementById('togOpacity').addEventListener('change', function(){Colors.Opacity = document.getElementById('togOpacity').value;t.Layout()}, false);
      document.getElementById('ResetALL').addEventListener ('click', function(){
      		RemoveList = (GM_listValues());
      		for (i=0;i<RemoveList.length;i++){
      			if (RemoveList[i] == "Colors") GM_deleteValue(RemoveList[i]);
      		}
      		ResetColors=true;
      		reloadKOC();
      },false);	
      
    } catch (e) {
      t.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  },
  
  Dashboard :function (){
    var t = Tabs.Options;  
    try {      
     	var left = '<TABLE id=pbDashOpts width=100% class=pbTab><TR>';
        left += '<TR><TD colspan=2>Show warnings when resources are below:</td></tr>';
        left += '<TR><TD style="width:50px;"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png"></td><TD><INPUT id=pbFoodWarning size=13 maxLength=12 type=text value='+DashboardOptions.foodLevel+'></td></tr>';
        left += '<TR><TD style="width:50px;"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png"></td><TD><INPUT id=pbWoodWarning size=13 maxLength=12 type=text value='+DashboardOptions.woodLevel+'></td></tr>';
        left += '<TR><TD style="width:50px;"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png"></td><TD><INPUT id=pbStoneWarning size=13 maxLength=12 type=text value='+DashboardOptions.stoneLevel+'></td></tr>';
        left += '<TR><TD style="width:50px;"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png"></td><TD><INPUT id=pbOreWarning size=13 maxLength=12 type=text value='+DashboardOptions.oreLevel+'></td></tr>';
        left += '<TR><TD style="width:50px;"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png"><TD><INPUT id=pbAStoneWarning size=8 maxLength=7 type=text value='+DashboardOptions.astoneLevel+'></td></tr></table>';
        var right = '<TABLE id=pbDashOptsSel width=100% class=pbTab>';
        right += '<TR><TD colspan=2>Select options you want to see in dashboard: (Refresh after toggle!)</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowThrone type=checkbox '+(DashboardOptions.showThrone?'CHECKED':'')+'>&nbsp; Show Throne Presets</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowRP type=checkbox '+(DashboardOptions.showRP?'CHECKED':'')+'>&nbsp; Show Rally Point Slots</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowStatus type=checkbox '+(DashboardOptions.showStatus?'CHECKED':'')+'>&nbsp; Show City Defensive Status (Green off, Red on)</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowTower type=checkbox '+(DashboardOptions.showTower?'CHECKED':'')+'>&nbsp; Show Tower Alerts</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowWarnings type=checkbox '+(DashboardOptions.showWarnings?'CHECKED':'')+'>&nbsp; Show Warnings</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowLog type=checkbox '+(DashboardOptions.showLog?'CHECKED':'')+'>&nbsp; Show Last 5 Log Items</td></tr>';
        right += '<TR><TD colspan=3><INPUT id=pbShowMarches type=checkbox '+(DashboardOptions.showMarches?'CHECKED':'')+'>&nbsp; Show Saved Marches</td></tr>';
        right +='</table>';
        var m = '<div class="pbStat">DASHBOARD OPTIONS</div><TABLE id=dbMain width=100% class=pbTab><TD>'+left+'</td><TD>'+right+'</td>';
        t.Overv.innerHTML = m;
        document.getElementById('pbFoodWarning').addEventListener('keyup',function(){DashboardOptions.foodLevel = this.value;saveDashboardOptions();},false);
        document.getElementById('pbWoodWarning').addEventListener('keyup',function(){DashboardOptions.woodLevel = this.value;saveDashboardOptions();},false);
        document.getElementById('pbStoneWarning').addEventListener('keyup',function(){DashboardOptions.stoneLevel = this.value;saveDashboardOptions();},false);
        document.getElementById('pbOreWarning').addEventListener('keyup',function(){DashboardOptions.oreLevel = this.value;saveDashboardOptions();},false);
        document.getElementById('pbAStoneWarning').addEventListener('keyup',function(){DashboardOptions.astoneLevel = this.value;saveDashboardOptions();},false);
        document.getElementById('pbShowThrone').addEventListener('change',function(){DashboardOptions.showThrone = document.getElementById('pbShowThrone').checked;saveDashboardOptions();},false);
        document.getElementById('pbShowRP').addEventListener('change',function(){DashboardOptions.showRP = document.getElementById('pbShowRP').checked;saveDashboardOptions();},false);
        document.getElementById('pbShowStatus').addEventListener('change',function(){DashboardOptions.showStatus = document.getElementById('pbShowStatus').checked;saveDashboardOptions();},false);
        document.getElementById('pbShowTower').addEventListener('change',function(){DashboardOptions.showTower = document.getElementById('pbShowTower').checked;saveDashboardOptions();},false);      
        document.getElementById('pbShowWarnings').addEventListener('change',function(){DashboardOptions.showWarnings = document.getElementById('pbShowWarnings').checked;saveDashboardOptions();},false);
        document.getElementById('pbShowLog').addEventListener('change',function(){DashboardOptions.showLog = document.getElementById('pbShowLog').checked;saveDashboardOptions();},false);
        document.getElementById('pbShowMarches').addEventListener('change',function(){DashboardOptions.showMarches = document.getElementById('pbShowMarches').checked;saveDashboardOptions();},false);     
    } catch (e) {
      t.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  },
  
  Export :function (){
    var t = Tabs.Options;  
    try {      
     	var m = '<div class="pbStat">OPTIONS EXPORT TOOL</div>';
        m+='<TABLE align="center"><TD><input type="submit" value="Import" id="pbImport_submit"></td><TD><input type="submit" value="Export" id="pbexport_submit"></td></table>';
        m+= '<BR><textarea type="text" id="pbImportData" rows=20 cols=80></textarea>';
         t.Overv.innerHTML = m;
        $('pbexport_submit').addEventListener('click', t.doExport, false);
        $('pbImport_submit').addEventListener('click', t.doImport, false);  
    } catch (e) {
      t.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  },
  doImport: function (){
      var t = Tabs.Options;
      var serverID = getServerId();
      var Data = JSON2.parse(document.getElementById('pbImportData').value);
      if (Data.TransportOptions != {}) Tabs.transport.tradeRoutes = Data.TransportOptions;
      Tabs.transport.saveTradeRoutes();
      if (Data.TransportState != {}) Tabs.transport.traderState = Data.TransportState;
      Tabs.transport.saveTraderState();
      if (Data.ReassignRoutes != {}) Tabs.Reassign.reassignRoutes = Data.ReassignRoutes;
      Tabs.Reassign.saveReassignRoutes();
      for (i=0;i<Seed.cities.length;i++) if (Data["Build" + (i+1)].length > 0) Tabs.build["bQ_" + Seed.cities[i][0]] = Data["Builds" + (i+1)];
      if (Data.Options != {}) Options = Data.Options;
      saveOptions();
      if (Data.GlobalOptions != {}) GlobalOptions = Data.GlobalOptions;
      GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));
      if (Data.ThroneOptions != {}) ThroneOptions = Data.ThroneOptions;
      saveThroneOptions();
      if (Data.TrainOptions != {}) TrainOptions = Data.TrainOptions;
      saveTrainOptions();
      if (Data.ApothecaryOptions != {}) ApothecaryOptions = Data.ApothecaryOptions;
      if (Data.FarmOptions != {}) FarmOptions = Data.FarmOptions;
      saveFarmOptions();
      if (Data.MarchOptions != {}) MarchOptions = Data.MarchOptions;
      saveMarchOptions();
      if (Data.Colors != {}) Colors = Data.Colors;
      saveColors();
      if (Data.ChatIcons != {}) ChatIcons = Data.ChatIcons;
      saveChatIcons();
      if (Data.CraftOptions != {}) CraftOptions = Data.CraftOptions;
      saveCraftOptions();
      if (Data.AtkOptions != {}) AtkOptions = Data.AtkOptions;
      saveAtkOptions();
      if (Data.DFOptions != {}) DFOptions = Data.DFOptions;
      saveDFOptions();
      if (Data.mercOptions != {}) mercOptions = Data.mercOptions;
      savemercOptions();
      if (Data.CrestOptions != {}) CrestOptions = Data.CrestOptions;
      saveCrestOptions();
      reloadKOC();    
    },
    doExport: function (){
      var t = Tabs.Options;
      var serverID = getServerId();
      for (i=0;i<Seed.cities.length;i++) t.Data["Build" + (i+1)] = JSON2.parse(GM_getValue('bQ_' + serverID + '_' + Seed.cities[i][0]));
      t.Data.TransportOptions = Tabs.transport.tradeRoutes;
      t.Data.TransportState = Tabs.transport.traderState
      t.Data.Options = Options;
      t.Data.GlobalOptions = GlobalOptions;
      t.Data.ThroneOptions = ThroneOptions;
      t.Data.CrestOptions = CrestOptions;
      t.Data.TrainOptions = TrainOptions;
      t.Data.DFOptions = DFOptions;
      t.Data.mercOptions = mercOptions;
      t.Data.ApothecaryOptions = ApothecaryOptions;
      t.Data.FarmOptions = FarmOptions;
      t.Data.MarchOptions = MarchOptions;
      t.Data.ReassignRoutes = Tabs.Reassign.reassignRoutes;
      t.Data.Colors = Colors;
      t.Data.ChatIcons = ChatIcons;
      t.Data.CraftOptions = CraftOptions;
      t.Data.AtkOptions = AtkOptions;
      document.getElementById('pbImportData').value = JSON2.stringify(t.Data);
      document.getElementById('pbImportData').select();
    },
  
  togOpt : function (checkboxId, optionName, callOnChange){
    var t = Tabs.Options;
    var checkbox = document.getElementById(checkboxId);
    if (Options[optionName]) checkbox.checked = true;
    checkbox.addEventListener ('change', eventHandler, false);
    function eventHandler (){
      Options[optionName] = this.checked;
      saveOptions();
      if (callOnChange) callOnChange (this.checked);
    }
  },
  
  changeOpt : function (valueId, optionName, callOnChange){
    var t = Tabs.Options;
    var e = document.getElementById(valueId);
    e.value = Options[optionName];
    e.addEventListener ('change', eventHandler, false);
    function eventHandler (){
      Options[optionName] = this.value;
      saveOptions();
      if (callOnChange) callOnChange (this.value);
    }
  },
  
  e_watchChanged : function (){
    GlobalOptions.pbWatchdog = document.getElementById('pbWatchEnable').checked;
    GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));  
  },
  
  e_wideChanged : function (){
    GlobalOptions.pbWideScreen = document.getElementById('pbWideOpt').checked;
    GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));  
  },
  
  e_updateChanged : function (){
    GlobalOptions.pbupdate = document.getElementById('pbupdate').checked;
    GM_setValue ('Options_??', JSON2.stringify(GlobalOptions));  
  },

  e_spamOptChanged : function (){
  var t = Tabs.Spam;
  Options.spamconfig.spamvert = document.getElementById('pbSpamAd').value;
  Options.spamconfig.spammins = document.getElementById('pbSpamMin').value;
  if(parseInt(Options.spamconfig.spammins) < 30){
   Options.spamconfig.spammins = 30;
   document.getElementById('pbSpamMin').value = 30;
  }
  saveOptions ();
 },

 togglespam: function(obj){
  if (Options.spamconfig.spamstate == 'a') {
   Options.spamconfig.spamstate = 'g';
   obj.value = "Send To  Global ";
  }
  else {
   Options.spamconfig.spamstate = 'a';
   obj.value = "Send To Alliance";
  }
  saveOptions ();
 },

 toggleon: function(obj){
  if (Options.spamconfig.aspam == true) {
   Options.spamconfig.aspam = false;
   obj.value = "Spam Off";
   obj.setAttribute("class", "buttonDash_OFF");
  }
  else {
   Options.spamconfig.aspam = true;	
   obj.value = "Spam On";
   obj.setAttribute("class", "buttonDash_ON");
   SpamEvery.init();
  }
  saveOptions ();
 },

  hide : function (){
  },

  show : function (){
  	 var t = Tabs.Options;
  	 switch (t.curTabName){
  	 	case 'Options': t.Options();break;
  	 	case 'Layout': t.Layout();break;
  	 	case 'Log': t.Paintlog();break;
  	 	case 'Dashboard': t.Dashboard();break; 
  	 	case 'Spam': t.spam();break;
  	 	case 'Export': t.Export();break; 	
  	 }   

  },

  onUnload : function (){
    var t = Tabs.Options;
    if (!ResetAll) GM_setValue ('log_'+getServerId(), JSON2.stringify(t.last250));
  },
  
}

/****************************  Reassign Implementation  *******************************/
var troops = {1:'SupplyTroops',
              2:'Militiaman',
              3:'Scout',
              4:'Pikeman',
              5:'Swordsman',
              6:'Archer',
              7:'Cavalry',
              8:'HeavyCavalry',
              9:'SupplyWagon',
              10:'Ballista',
              11:'BatteringRam',
              12:'Catapult',
              13:'Bloodthorn',
              14:'Executioner',
              15:'SiegeWall',
              16:'FlameArcher',
              17: 'Hussar'};  

Tabs.Reassign = {

  tabOrder: 30,
  tabLabel: 'Reassign',
  myDiv: null,
  timer: null,
  reassignState: [],
  lRE: [],
  reassignRoutes: [],
  rallypointlevel:null,
  count:0,
  check:false,

    init: function(div){
        var t = Tabs.Reassign;
        t.myDiv = div;
        t.reassignState = {
            running: false,
        };
        t.readReassignState();
        t.readReassignRoutes();
        t.e_reassignRoutes();

      var m = '<DIV id=pbReMainDivF class=pbStat>'+translate("AUTOMATED REASSIGN FUNCTION")+'</div><TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center">';
      m+='<TD><INPUT class="buttonDash_'+ (t.reassignState.running?'ON':'OFF') +'" id=pbReassignState type=submit value="'+translate("Reassign")+' = '+ (t.reassignState.running?'ON':'OFF')+'"></td>';
      m += '<TD><INPUT id=pbReassShowRoutes type=submit class=pbButton value="Show Routes"></td>';
      m += '</tr></table></div>';
      m += '<DIV id=pbReassignDivD class=pbStat>'+translate("ADD REASSIGN ROUTE")+'</div>';

      m += '<TABLE id=pbaddreasignroute width=95% height=0% class=pbTab><TR align="left">';
      m += '<TD width=20px>'+translate("From City:")+'</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptassigncity></span></div></td></tr>';

      m += '<TR align="left">';
      m += '<TD width=20px>'+translate("To City:")+'</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptassigncityTo></span></div></td>';
      
        m += '<TR align="left">';
        m += '<TD colspan=4>'+translate("Check reassign every:")+' <INPUT id=pbreassigninterval type=text size=2 value="'+Options.reassigninterval+'"> '+translate("minutes")+'</td></tr>';
        m += '<TR><TD><INPUT id=autofilloff type=checkbox unchecked=true> '+translate("Lock troop values")+'</TR></TD></table>';
      m += '<DIV style="margin-top:10px;margin-bottom:5px;">'+translate("Fill in the number of troops you want to keep in a city:")+'</div>';
      m += '<TABLE id=pbaddreasignroute width=100% height=0% class=pbTab><TR align="center">';
      
      m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_1_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Supply Troop")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_2_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Militiaman")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_3_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Scout")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_4_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Pikeman")+'</td></tr>';
      m += '<TR><TD><INPUT id=pbSupplyTroops type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetSupplyTroops disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbMilitiaman type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetMilitiaman disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbScout type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetScout disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbPikeman type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetPikeman disabled=true type=text size=10 maxlength=10 value="0"></td></tr>';
      
      m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_5_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Swordsman")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_6_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Archer")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_7_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Cavalry")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_8_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Heavy Cavalry")+'</td></tr>';
      m += '<TR><TD><INPUT id=pbSwordsman type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetSwordsman disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbArcher type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetArcher disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbCavalry type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetCavalry disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbHeavyCavalry type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetHeavyCavalry disabled=true type=text size=10 maxlength=10 value="0"></td></tr>';
      
      m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_9_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Supply Wagon")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_10_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Ballista")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_11_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Battering Ram")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_12_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Catapult")+'</td></tr>';
      m += '<TR><TD><INPUT id=pbSupplyWagon type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetSupplyWagon disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbBallista type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetBallista disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbBatteringRam type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetBatteringRam disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbCatapult type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetCatapult disabled=true type=text size=10 maxlength=10 value="0"></td></tr>';

      m += '<TR><TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_13_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Bloodthorn")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_14_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Executioner")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_15_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Siege Wall")+'</td>';
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_16_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Flame Archer")+'</td></tr>';
      m += '<TR><TD><INPUT id=pbBloodthorn type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetBloodthorn disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbExecutioner type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetExecutioner disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbSiegeWall type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetSiegeWall disabled=true type=text size=10 maxlength=10 value="0"></td>';
      m += '<TD><INPUT id=pbFlameArcher type=checkbox unchecked=true>';
      m += '<INPUT id=pbtargetFlameArcher disabled=true type=text size=10 maxlength=10 value="0"></td></tr>';
      
      m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_17_30.jpg?6545?6545"></td>';
      m += '<TD>'+translate("Hussar")+'</td></tr>';
      m += '<TR><TD><INPUT id=pbHussar type=checkbox unchecked=true>';
       m += '<INPUT id=pbtargetHussar disabled=true type=text size=10 maxlength=10 value="0"></td></tr></table>';
       
      m += '<DIV style="text-align:center; margin-top:15px"><INPUT id=pbSaveRouteReassign type=submit class=pbButton value="'+translate("Add Route")+'"></div>';
      
      t.myDiv.innerHTML = m;
      
      t.tcp = new CdispCityPicker ('ptreassign', document.getElementById('ptassigncity'), true, null, 0);
      t.tcpto = new CdispCityPicker ('ptreassignTo', document.getElementById('ptassigncityTo'), true);
      for(var k in troops) document.getElementById('pbtarget'+troops[k]).value = parseInt(Seed.units['city' + t.tcp.city.id]['unt'+k]);

      document.getElementById('ptassigncity').addEventListener('click', function(){if(document.getElementById('autofilloff').checked == false) for(var k in troops) document.getElementById('pbtarget'+troops[k]).value = parseInt(Seed.units['city' + t.tcp.city.id]['unt'+k]);}, false);
      document.getElementById('pbReassignState').addEventListener('click', function(){t.toggleReassignState(this);}, false);
      document.getElementById('pbSaveRouteReassign').addEventListener('click', function(){t.addReassignRoute();}, false);
      document.getElementById('pbReassShowRoutes').addEventListener('click', function(){t.showReassignRoutes();}, false);
      
      document.getElementById('pbreassigninterval').addEventListener('keyup', function(){
        if (isNaN(document.getElementById('pbreassigninterval').value) || document.getElementById('pbreassigninterval').value<1){ document.getElementById('pbreassigninterval').value=1 ;}
        Options.reassigninterval = document.getElementById('pbreassigninterval').value;
        saveOptions();
      }, false);
      
    document.getElementById('pbtargetSupplyTroops').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetSupplyTroops').value)) document.getElementById('pbtargetSupplyTroops').value=0 ;}, false);
    document.getElementById('pbtargetMilitiaman').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetMilitiaman').value)) document.getElementById('pbtargetMilitiaman').value=0 ;}, false);
    document.getElementById('pbtargetScout').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetScout').value)) document.getElementById('pbtargetScout').value=0 ;}, false);
    document.getElementById('pbtargetPikeman').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetPikeman').value)) document.getElementById('pbtargetPikeman').value=0 ;}, false);
    document.getElementById('pbtargetSwordsman').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetSwordsman').value)) document.getElementById('pbtargetSwordsman').value=0 ;}, false);
    document.getElementById('pbtargetArcher').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetArcher').value)) document.getElementById('pbtargetArcher').value=0 ;}, false);
    document.getElementById('pbtargetCavalry').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetCavalry').value)) document.getElementById('pbtargetCavalry').value=0 ;}, false);
    document.getElementById('pbtargetHeavyCavalry').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetHeavyCavalry').value)) document.getElementById('pbtargetHeavyCavalry').value=0 ;}, false);
    document.getElementById('pbtargetSupplyWagon').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetSupplyWagon').value)) document.getElementById('pbtargetSupplyWagon').value=0 ;}, false);
    document.getElementById('pbtargetBallista').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetBallista').value)) document.getElementById('pbtargetBallista').value=0 ;}, false);
    document.getElementById('pbtargetBatteringRam').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetBatteringRam').value)) document.getElementById('pbtargetBatteringRam').value=0 ;}, false);
    document.getElementById('pbtargetCatapult').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetCatapult').value)) document.getElementById('pbtargetCatapult').value=0 ;}, false);
    document.getElementById('pbtargetBloodthorn').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetBloodthorn').value)) document.getElementById('pbtargetBloodthorn').value=0 ;}, false);
	document.getElementById('pbtargetExecutioner').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetExecutioner').value)) document.getElementById('pbtargetExecutioner').value=0 ;}, false);
	document.getElementById('pbtargetSiegeWall').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetSiegeWall').value)) document.getElementById('pbtargetSiegeWall').value=0 ;}, false);
	document.getElementById('pbtargetFlameArcher').addEventListener('keyup', function(){if (isNaN(document.getElementById('pbtargetFlameArcher').value)) document.getElementById('pbtargetFlameArcher').value=0 ;}, false);
      
      document.getElementById('pbSupplyTroops').addEventListener('click', function(){
          if (document.getElementById('pbSupplyTroops').checked==false) {
              document.getElementById('pbtargetSupplyTroops').disabled = true;
          }
          else {
            document.getElementById('pbtargetSupplyTroops').disabled = false;
          }
      },false);
      document.getElementById('pbMilitiaman').addEventListener('click', function(){
          if (document.getElementById('pbMilitiaman').checked==false) {
              document.getElementById('pbtargetMilitiaman').disabled = true;
          }
          else {
            document.getElementById('pbtargetMilitiaman').disabled = false;
          }
      },false);
      document.getElementById('pbScout').addEventListener('click', function(){
          if (document.getElementById('pbScout').checked==false) {
              document.getElementById('pbtargetScout').disabled = true;
          }
          else {
            document.getElementById('pbtargetScout').disabled = false;
          }
      },false);
      document.getElementById('pbPikeman').addEventListener('click', function(){
          if (document.getElementById('pbPikeman').checked==false) {
              document.getElementById('pbtargetPikeman').disabled = true;
          }
          else {
            document.getElementById('pbtargetPikeman').disabled = false;
          }
      },false);
      document.getElementById('pbSwordsman').addEventListener('click', function(){
          if (document.getElementById('pbSwordsman').checked==false) {
              document.getElementById('pbtargetSwordsman').disabled = true;
          }
          else {
            document.getElementById('pbtargetSwordsman').disabled = false;
          }
      },false);
      document.getElementById('pbArcher').addEventListener('click', function(){
          if (document.getElementById('pbArcher').checked==false) {
              document.getElementById('pbtargetArcher').disabled = true;
          }
          else {
            document.getElementById('pbtargetArcher').disabled = false;
          }
      },false);
      document.getElementById('pbCavalry').addEventListener('click', function(){
          if (document.getElementById('pbCavalry').checked==false) {
              document.getElementById('pbtargetCavalry').disabled = true;
          }
          else {
            document.getElementById('pbtargetCavalry').disabled = false;
          }
      },false);
      document.getElementById('pbHeavyCavalry').addEventListener('click', function(){
          if (document.getElementById('pbHeavyCavalry').checked==false) {
              document.getElementById('pbtargetHeavyCavalry').disabled = true;
          }
          else {
            document.getElementById('pbtargetHeavyCavalry').disabled = false;
          }
      },false);
      document.getElementById('pbSupplyWagon').addEventListener('click', function(){
          if (document.getElementById('pbSupplyWagon').checked==false) {
              document.getElementById('pbtargetSupplyWagon').disabled = true;
          }
          else {
            document.getElementById('pbtargetSupplyWagon').disabled = false;
          }
      },false);
      document.getElementById('pbBallista').addEventListener('click', function(){
          if (document.getElementById('pbBallista').checked==false) {
              document.getElementById('pbtargetBallista').disabled = true;
          }
          else {
            document.getElementById('pbtargetBallista').disabled = false;
          }
      },false);
      document.getElementById('pbBatteringRam').addEventListener('click', function(){
          if (document.getElementById('pbBatteringRam').checked==false) {
              document.getElementById('pbtargetBatteringRam').disabled = true;
          }
          else {
            document.getElementById('pbtargetBatteringRam').disabled = false;
          }
      },false);
      document.getElementById('pbCatapult').addEventListener('click', function(){
          if (document.getElementById('pbCatapult').checked==false) {
              document.getElementById('pbtargetCatapult').disabled = true;
          }
          else {
            document.getElementById('pbtargetCatapult').disabled = false;
          }
      },false);
      document.getElementById('pbBloodthorn').addEventListener('click', function(){
          if (document.getElementById('pbBloodthorn').checked==false) {
              document.getElementById('pbtargetBloodthorn').disabled = true;
          }
          else {
            document.getElementById('pbtargetBloodthorn').disabled = false;
          }
      },false);
      document.getElementById('pbExecutioner').addEventListener('click', function(){
          if (document.getElementById('pbExecutioner').checked==false) {
              document.getElementById('pbtargetExecutioner').disabled = true;
          }
          else {
            document.getElementById('pbtargetExecutioner').disabled = false;
          }
      },false);
      document.getElementById('pbSiegeWall').addEventListener('click', function(){
          if (document.getElementById('pbSiegeWall').checked==false) {
              document.getElementById('pbtargetSiegeWall').disabled = true;
          }
          else {
            document.getElementById('pbtargetSiegeWall').disabled = false;
          }
      },false);
      document.getElementById('pbFlameArcher').addEventListener('click', function(){
          if (document.getElementById('pbFlameArcher').checked==false) {
              document.getElementById('pbtargetFlameArcher').disabled = true;
          }
          else {
            document.getElementById('pbtargetFlameArcher').disabled = false;
          }
      },false);
      document.getElementById('pbHussar').addEventListener('click', function(){
          if (document.getElementById('pbHussar').checked==false) {
              document.getElementById('pbtargetHussar').disabled = true;
          }
          else {
            document.getElementById('pbtargetHussar').disabled = false;
          }
      },false);
      
      window.addEventListener('unload', t.onUnload, false);
    },
    
	getRallypoint: function(cityId){
	var t = Tabs.Reassign;
	for (var o in Seed.buildings[cityId]){
	var buildingType = parseInt(Seed.buildings[cityId][o][0]);
	var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
	if (buildingType == 12) t.rallypointlevel=parseInt(buildingLevel);
		}
	if(t.rallypointlevel == 11) t.rallypointlevel = 15;
	if(t.rallypointlevel == 12) t.rallypointlevel = 20;
    },	
	
    e_reassignRoutes: function(){
      var t = Tabs.Reassign;
      var now = new Date();
      if (t.reassignState.running == true)    {
          now = new Date().getTime()/1000.0;
          now = now.toFixed(0);
          var last = Options.lastreassign;
               if ( now > (parseInt(last) + (Options.reassigninterval*60))){
                  t.checkdoReassign();
              }
      }
      setTimeout(function(){ t.e_reassignRoutes();}, Options.reassigninterval*1000);
      
    },
        
    delReassignRoutes: function() {     
        var t = Tabs.Reassign;       
        t.reassignRoutes= [];
    },
    checkcoords : function (obj){
        var t = Tabs.Reassign;
        if(obj.id == 'pbok'){
            t.check = true;
            t.addReassignRoute();
        }
        return;            
    },
    addReassignRoute: function () {
        var t = Tabs.Reassign;
        var city = t.tcp.city.id;
        if(t.tcpto.city == null){
            new CdialogCancelContinue('<SPAN class=boldRed>'+translate("No destination selected!")+'</span>', null, null, mainPop.getMainDiv);
            return;
        }
        if(t.tcp.city.id == t.tcpto.city.id){
            new CdialogCancelContinue('<SPAN class=boldRed>'+translate("Can\'t reassign to same city!")+'</span>', null, null, mainPop.getMainDiv);
            return;
        }
        if ((t.tcpto.city.x == 0 && t.tcpto.city.y == 0)&& !t.check)
        {
            new CdialogConfirm ('<SPAN class=boldRed>'+translate("You are about to set a route to location 0,0!")+'</span>', t.checkcoords, unsafeWindow.modal_attack_check, mainPop.getMainDiv);
            return;
        }
        t.check = false;
        
        var SendSupplyTroop = document.getElementById('pbSupplyTroops').checked;
        var SendMilitiaman = document.getElementById('pbMilitiaman').checked;
        var SendScout = document.getElementById('pbScout').checked;
        var SendPikeman = document.getElementById('pbPikeman').checked;
        var SendSwordsman = document.getElementById('pbSwordsman').checked;
        var SendArchers = document.getElementById('pbArcher').checked;
        var SendCavalry = document.getElementById('pbCavalry').checked;
        var SendHeavyCavalry = document.getElementById('pbHeavyCavalry').checked;
        var SendSupplyWagons = document.getElementById('pbSupplyWagon').checked;
        var SendBallista = document.getElementById('pbBallista').checked;
        var SendBatteringRam = document.getElementById('pbBatteringRam').checked;
        var SendCatapult = document.getElementById('pbCatapult').checked;
		var SendBloodthorn = document.getElementById('pbBloodthorn').checked;
		var SendExecutioner = document.getElementById('pbExecutioner').checked;
		var SendSiegeWall = document.getElementById('pbSiegeWall').checked;
		var SendFlameArcher = document.getElementById('pbFlameArcher').checked;
    var SendHussar = document.getElementById('pbHussar').checked;		
        var SupplyTroop = document.getElementById('pbtargetSupplyTroops').value;
        var Militiaman = document.getElementById('pbtargetMilitiaman').value;
        var Scout = document.getElementById('pbtargetScout').value;
        var Pikeman = document.getElementById('pbtargetPikeman').value;
        var Swordsman = document.getElementById('pbtargetSwordsman').value;
        var Archers = document.getElementById('pbtargetArcher').value;
        var Cavalry = document.getElementById('pbtargetCavalry').value;
        var HeavyCavalry = document.getElementById('pbtargetHeavyCavalry').value;
        var SupplyWagons = document.getElementById('pbtargetSupplyWagon').value;
        var Ballista = document.getElementById('pbtargetBallista').value;
        var BatteringRam = document.getElementById('pbtargetBatteringRam').value;
        var Catapult = document.getElementById('pbtargetCatapult').value;
		var Bloodthorn = document.getElementById('pbtargetBloodthorn').value;
		var Executioner = document.getElementById('pbtargetExecutioner').value;
		var SiegeWall = document.getElementById('pbtargetSiegeWall').value;
		var FlameArcher = document.getElementById('pbtargetFlameArcher').value;
		var Hussar = document.getElementById('pbtargetHussar').value;
        var target_x = t.tcpto.city.x;
        var target_y = t.tcpto.city.y;
        var target_city = t.tcpto.city.id;
                
        var lRE = t.reassignRoutes;
            lRE.push({
                city:                city,
                target_x:            target_x,
                target_y:            target_y,
                target_city:        target_city,
                SendSupplyTroop:    SendSupplyTroop,
                SupplyTroop:        SupplyTroop,
                SendMilitiaman:        SendMilitiaman,
                Militiaman:            Militiaman,
                SendScout:            SendScout,
                Scout:                Scout,
                SendPikeman:         SendPikeman,
                Pikeman:             Pikeman,
                SendSwordsman:        SendSwordsman,
                Swordsman:            Swordsman,
                SendArchers:        SendArchers,
                Archers:            Archers,
                SendCavalry:         SendCavalry,
                Cavalry:             Cavalry,
                SendHeavyCavalry:    SendHeavyCavalry,
                HeavyCavalry:        HeavyCavalry,
                SendSupplyWagons:    SendSupplyWagons,
                SupplyWagons:        SupplyWagons,
                SendBallista:        SendBallista,
                Ballista:            Ballista,
                SendBatteringRam:    SendBatteringRam,
                BatteringRam:        BatteringRam,
				        Catapult:            Catapult,
                SendCatapult:        SendCatapult,
                Bloodthorn:          Bloodthorn,
				        SendBloodthorn:      SendBloodthorn,
                Executioner:         Executioner,
				        SendExecutioner:     SendExecutioner,
                SiegeWall:           SiegeWall,
				        SendSiegeWall:       SendSiegeWall,
                FlameArcher:         FlameArcher,
				        SendFlameArcher:     SendFlameArcher,
        Hussar:         Hussar,
				SendHussar:     SendHussar});
				
        document.getElementById('pbReassignDivD').style.background ='#99FF99';
        setTimeout(function(){ (document.getElementById('pbReassignDivD').style.background =''); }, 1000);
    },
    showReassignRoutes: function () {
        var t = Tabs.Reassign;
        var popReassignRoutes = null;
        t.popReassignRoutes = new pbPopup('pbShowTrade', 0, 0, 1100, 485, true, function() {clearTimeout (1000);});
        var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbShowReassignRoutes" id="pbRoutesQueue">';       
        t.popReassignRoutes.getMainDiv().innerHTML = '</table></div>' + m;
        t.popReassignRoutes.getTopDiv().innerHTML = '<TD><CENTER><B>'+translate("Reassign routes")+'</center></td>';
        t.paintReassignRoutes();
        t._addTabHeader();
        t.popReassignRoutes.show(true)    ;
    },
    paintReassignRoutes: function(){
            var t = Tabs.Reassign;
            var r = t.reassignRoutes;
            var cityname;
            for (var i = (r.length-1); i>=0; i--) {
                for (var y=0; y< Seed.cities.length;y++) {
                    if ( parseInt(Seed.cities[y][0]) == r[i].city) var cityname = Seed.cities[y][1];
                }    
                var queueId = i;
                t._addTab(queueId,cityname, r[i].target_x, r[i].target_y, r[i].target_city, r[i].SendSupplyTroop,r[i].SupplyTroop, r[i].SendMilitiaman, r[i].Militiaman, r[i].SendScout, r[i].Scout, r[i].SendPikeman, r[i].Pikeman, r[i].SendSwordsman, r[i].Swordsman, r[i].SendArchers, r[i].Archers, r[i].SendCavalry, r[i].Cavalry, r[i].SendHeavyCavalry, r[i].HeavyCavalry, r[i].SendSupplyWagons, r[i].SupplyWagons, r[i].SendBallista, r[i].Ballista, r[i].SendBatteringRam, r[i].BatteringRam, r[i].SendCatapult, r[i].Catapult, r[i].SendBloodthorn, r[i].Bloodthorn, r[i].SendExecutioner, r[i].Executioner, r[i].SendSiegeWall, r[i].SiegeWall, r[i].SendFlameArcher, r[i].FlameArcher, r[i].SendHussar, r[i].Hussar);
            }
        },
      
     _addTab: function(queueId,cityname,target_x,target_y,target_city,SendSupplyTroop,SupplyTroop,SendMilitiaman,Militiaman,SendScout,Scout,SendPikeman,Pikeman,SendSwordsman,Swordsman,SendArchers,Archers,SendCavalry,Cavalry,SendHeavyCavalry,HeavyCavalry,SendSupplyWagons,SupplyWagons,SendBallista,Ballista,SendBatteringRam,BatteringRam,SendCatapult,Catapult,SendBloodthorn,Bloodthorn,SendExecutioner,Executioner,SendSiegeWall,SiegeWall,SendFlameArcher,FlameArcher,SendHussar,Hussar){
         var t = Tabs.Reassign;
        var To = target_x+','+target_y;
        for (var y=0; y< Seed.cities.length;y++) {
            if ( parseInt(Seed.cities[y][0]) == parseInt(target_city)){
                To = Seed.cities[y][1];
                break;
            }
        }
         var row = document.getElementById('pbRoutesQueue').insertRow(0);
         row.vAlign = 'top';
         row.insertCell(0).innerHTML = queueId;
         row.insertCell(1).innerHTML = cityname;
         row.insertCell(2).innerHTML = To;
         row.insertCell(3).innerHTML = SendSupplyTroop;
         row.insertCell(4).innerHTML = addCommas(SupplyTroop);
         row.insertCell(5).innerHTML = SendMilitiaman;
         row.insertCell(6).innerHTML = addCommas(Militiaman);
          row.insertCell(7).innerHTML = SendScout;
          row.insertCell(8).innerHTML = addCommas(Scout);
          row.insertCell(9).innerHTML = SendPikeman;
          row.insertCell(10).innerHTML = addCommas(Pikeman);
          row.insertCell(11).innerHTML = SendSwordsman;
          row.insertCell(12).innerHTML = addCommas(Swordsman);
          row.insertCell(13).innerHTML = SendArchers;
          row.insertCell(14).innerHTML = addCommas(Archers);
          row.insertCell(15).innerHTML = SendCavalry;
          row.insertCell(16).innerHTML = addCommas(Cavalry);
          row.insertCell(17).innerHTML = SendHeavyCavalry;
          row.insertCell(18).innerHTML = addCommas(HeavyCavalry);
          row.insertCell(19).innerHTML = SendSupplyWagons;
          row.insertCell(20).innerHTML = addCommas(SupplyWagons);
          row.insertCell(21).innerHTML = SendBallista;
          row.insertCell(22).innerHTML = addCommas(Ballista);
          row.insertCell(23).innerHTML = SendBatteringRam;
          row.insertCell(24).innerHTML = addCommas(BatteringRam);
          row.insertCell(25).innerHTML = SendCatapult;
          row.insertCell(26).innerHTML = addCommas(Catapult);
          row.insertCell(27).innerHTML = SendBloodthorn;
          row.insertCell(28).innerHTML = addCommas(Bloodthorn);
          row.insertCell(29).innerHTML = SendExecutioner;
          row.insertCell(30).innerHTML = addCommas(Executioner);
          row.insertCell(31).innerHTML = SendSiegeWall;
          row.insertCell(32).innerHTML = addCommas(SiegeWall);
          row.insertCell(33).innerHTML = SendFlameArcher;
          row.insertCell(34).innerHTML = addCommas(FlameArcher);
          row.insertCell(35).innerHTML = SendHussar;
          row.insertCell(36).innerHTML = addCommas(Hussar);
		  row.insertCell(37).innerHTML = '<a class="button20" id="tradecancel_' + queueId + '"><span>'+translate("Delete")+'</span></a>';
         document.getElementById('tradecancel_' + queueId).addEventListener('click', function(){
            t.cancelQueueElement(queueId);
         }, false);
     },
     
     _addTabHeader: function() {
     var t = Tabs.transport;
         var row = document.getElementById('pbRoutesQueue').insertRow(0);
         row.vAlign = 'top';
         row.insertCell(0).innerHTML = "ID";
         row.insertCell(1).innerHTML = translate("From");
         row.insertCell(2).innerHTML = translate("To");
         row.insertCell(3).innerHTML = translate("Sup. Tr.");
         row.insertCell(4).innerHTML = "";
         row.insertCell(5).innerHTML = translate("MM");
         row.insertCell(6).innerHTML = "";
         row.insertCell(7).innerHTML = translate("Scouts");
         row.insertCell(8).innerHTML = "";
         row.insertCell(9).innerHTML = translate("Pikes");
         row.insertCell(10).innerHTML = "";
         row.insertCell(11).innerHTML = translate("Swords");
         row.insertCell(12).innerHTML = "";
         row.insertCell(13).innerHTML = translate("Archers");
         row.insertCell(14).innerHTML = "";
         row.insertCell(15).innerHTML = translate("Cav");
         row.insertCell(16).innerHTML = "";
         row.insertCell(17).innerHTML = translate("HC");
         row.insertCell(18).innerHTML = "";
         row.insertCell(19).innerHTML = translate("Wagons");
         row.insertCell(20).innerHTML = "";
         row.insertCell(21).innerHTML = translate("Ballista");
         row.insertCell(22).innerHTML = "";
         row.insertCell(23).innerHTML = translate("Rams");
         row.insertCell(24).innerHTML = "";
         row.insertCell(25).innerHTML = translate("Cats");
         row.insertCell(26).innerHTML = "";
         row.insertCell(27).innerHTML = translate("Bloodthorn");
         row.insertCell(28).innerHTML = "";
         row.insertCell(29).innerHTML = translate("Exec");
         row.insertCell(30).innerHTML = "";
         row.insertCell(31).innerHTML = translate("Siege");
         row.insertCell(32).innerHTML = "";
         row.insertCell(33).innerHTML = translate("FlmArch");
         row.insertCell(34).innerHTML = "";
         row.insertCell(35).innerHTML = translate("Hussar");
         row.insertCell(36).innerHTML = "";
         row.insertCell(37).innerHTML = translate("Delete");
		 },
       
     cancelQueueElement: function(queueId){
         var t = Tabs.Reassign;
         var queueId = parseInt(queueId);
         t.reassignRoutes.splice(queueId, 1);
         t.showReassignRoutes();
     },
       
    saveReassignRoutes: function(){
        var t = Tabs.Reassign;
        var serverID = getServerId();
        GM_setValue('reassignRoutes_' + serverID, JSON2.stringify(t.reassignRoutes));
    },

    readReassignRoutes: function(){
        var t = Tabs.Reassign;
        var serverID = getServerId();
        s = GM_getValue('reassignRoutes_' + serverID);
        if (s != null) {
            route = JSON2.parse(s);
            for (k in route)
                t.reassignRoutes[k] = route[k];
        }
        try{
            t.checkcitymoved();
        } catch (e) {
            //Do nothing
        }
    },
    checkcitymoved: function(){
        var t = Tabs.Reassign;
        for(var i=0; i < t.reassignRoutes.length; i++){
			if(Cities.byID[t.reassignRoutes[i].target_city] == 'undefined'){
				cancelQueueElement[i];
				return;
				}
            if(t.reassignRoutes[i].target_city == 'undefined') break;
            if(t.reassignRoutes[i].target_x != Cities.byID[t.reassignRoutes[i].target_city].x) t.reassignRoutes[i].target_x = Cities.byID[t.reassignRoutes[i].target_city].x;
            if(t.reassignRoutes[i].target_y != Cities.byID[t.reassignRoutes[i].target_city].y) t.reassignRoutes[i].target_y = Cities.byID[t.reassignRoutes[i].target_city].y;
        }
    },
    saveReassignState: function(){
        var t = Tabs.Reassign;
        var serverID = getServerId();
        GM_setValue('reassignState_' + serverID, JSON2.stringify(t.reassignState));
    },
    readReassignState: function(){
        var t = Tabs.Reassign;
        var serverID = getServerId();
        s = GM_getValue('reassignState_' + serverID);
        if (s != null) {
            state = JSON2.parse(s);
            for (k in state)
                t.reassignState[k] = state[k];
        }
    },
    toggleReassignState: function(obj){
        var t = Tabs.Reassign;
        if (t.reassignState.running == true) {
            t.reassignState.running = false;
            if (document.getElementById('pbReassignState')) {document.getElementById('pbReassignState').value = "Reassign = OFF";document.getElementById('pbReassignState').setAttribute("class", "buttonDash_OFF");}
        	if (document.getElementById('ReassignToggle')) {document.getElementById('ReassignToggle').value = "Reassign = OFF";document.getElementById('ReassignToggle').setAttribute("class", "buttonDash_OFF");}
            t.checkdoreassigntimeout = null;
            t.count = 0;
        }
        else {
            t.reassignState.running = true;
            if (document.getElementById('pbReassignState')) {document.getElementById('pbReassignState').value = "Reassign = ON";document.getElementById('pbReassignState').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('ReassignToggle')) {document.getElementById('ReassignToggle').value = "Reassign = ON";document.getElementById('ReassignToggle').setAttribute("class", "buttonDash_ON");}
            t.e_reassignRoutes();
        }
    },
    
    checkdoReassign: function(){
    var t = Tabs.Reassign;
    t.doReassign(t.count);
    t.count++;
        if(t.count < t.reassignRoutes.length && t.reassignState.running){
          t.checkdoreassigntimeout = setTimeout(function() { t.checkdoReassign();}, 5000);
        } else {
          var now = new Date().getTime()/1000.0;
          now = now.toFixed(0);
          Options.lastreassign = now;
          saveOptions();    
          t.count = 0;
        }
    },
    
    doReassign: function(count){
        var t = Tabs.Reassign;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        if(t.reassignRoutes.length==0) return;
        var send=[];
        var citytotal=0;
        var totalsend=0;
        params.u1 = 0;
        params.u2 = 0;
        params.u3 = 0;
        params.u4 = 0;
        params.u5 = 0;
        params.u6 = 0;
        params.u7 = 0;
        params.u8 = 0;
        params.u9 = 0;
        params.u10 = 0;
        params.u11 = 0;
        params.u12 = 0;
		    params.u13 = 0;
		    params.u14 = 0;	
        params.u15 = 0;
		    params.u16 = 0;
        params.u17 = 0;
		
        var city = t.reassignRoutes[count]["city"];
        var xcoord = t.reassignRoutes[count]["target_x"];
        var ycoord = t.reassignRoutes[count]["target_y"];
    
//* To Do, Factor out Max March Size  
        var cityID = 'city' + city;
        if(!Cities.byID[city]) return;
        var marching = getMarchInfo(cityID);
		t.getRallypoint(cityID);
		var RallypointMax = (t.rallypointlevel * 10000);
		var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
		if (TR > 150) TR=150;		
        var maxsend = 0;
		maxsend = RallypointMax + Math.floor(RallypointMax * (TR / 100));
		var prestigeRallyPercent = 1.40;
		if (Seed.cityData.city[city].isPrestigeCity) {
			for (var i=1;i<=6;i++){
				i <= 2 ? prestigeRallyPercent += 0.10 : prestigeRallyPercent += 0.05;
				if (i == (parseInt(Seed.cityData.city[city].prestigeInfo.prestigeLevel))){ maxsend = Math.floor(maxsend * prestigeRallyPercent);break;}				
			}
		}
//*/
        totalsend=0;
        var troopsselect=["SupplyTroop","Militiaman","Scout","Pikeman","Swordsman","Archers","Cavalry","HeavyCavalry","SupplyWagons","Ballista","BatteringRam","Catapult","Bloodthorn","Executioner","SiegeWall","FlameArcher","Hussar"];
        for (k=0; k<troopsselect.length; k++) {
            var citytroops = 0;
			citytroops = Seed.units[cityID]['unt'+(parseInt(k)+1)];
            var marchtroops = 0;
			marchtroops = marching.marchUnits[parseInt(k)+1];
            citytotal = parseInt(citytroops) + parseInt(marchtroops);
            if(t.reassignRoutes[count]['Send'+troopsselect[k]]==false) {continue; }
            if(citytotal > t.reassignRoutes[count][troopsselect[k]]){
                var sendtroops = parseInt(citytotal) - parseInt(t.reassignRoutes[count][troopsselect[k]]);
                if (parseInt(sendtroops) > parseInt(citytroops)) sendtroops = citytroops;
                if (parseInt(sendtroops) < 0) sendtroops = 0;
                send[(parseInt(k)+1)] = sendtroops;
                totalsend += send[(parseInt(k)+1)];                
            }
            if(totalsend > maxsend){
                totalsend -= send[(parseInt(k)+1)];
                send[(parseInt(k)+1)] = parseInt(maxsend-totalsend);
                totalsend += send[(parseInt(k)+1)];
                break;
            }
        }
        
        for (var t=0; t< Seed.cities.length;t++) {
            if ( parseInt(Seed.cities[t][0]) == city) var cityname = Seed.cities[t][1];
        }
        
        params.cid= city;
        params.type = "5";
        params.kid=0;
        params.xcoord = xcoord;
        params.ycoord = ycoord;
        params.u1 = send[1];
        params.u2 = send[2];
        params.u3 = send[3];
        params.u4 = send[4];
        params.u5 = send[5];
        params.u6 = send[6];
        params.u7 = send[7];
        params.u8 = send[8];
        params.u9 = send[9];
        params.u10 = send[10];
        params.u11 = send[11];
        params.u12 = send[12];
		    params.u13 = send[13];
		    params.u14 = send[14];
		    params.u15 = send[15];
		    params.u16 = send[16];
        params.u17 = send[17];
        
           if (totalsend >0) {
           
        var profiler = new unsafeWindow.cm.Profiler("ResponseTime", "march.php");
        RPM++;
              new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
                  method: "post",
                  parameters: params,
                  loading: true,
                  onSuccess: function (transport) {
                      profiler.stop();
                  var rslt = eval("(" + transport.responseText + ")");
                  if (rslt.ok) {
	                  actionLog('Reassign   From: ' + cityname + "   To: " + xcoord + ',' + ycoord + "    ->   Troops: " + totalsend);
	                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                  var ut = unixTime();
	                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	                                      for(i = 0; i <= unitsarr.length; i++){
	                                          if(params["u"+i]){
	                                                  unitsarr[i] = params["u"+i];
	                                          }
	                                      }
	                  var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	                  var currentcityid = city;
	                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                  if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                  } 
                  },
                  onFailure: function () {profiler.stop();}
          });
        }      
    },
    
    show: function(){
        var t = Tabs.Reassign;
    },
    hide: function(){
        var t = Tabs.Reassign;
    },
    onUnload: function(){
        var t = Tabs.Reassign;
        if (!ResetAll) t.saveReassignRoutes();
        if (!ResetAll) t.saveReassignState();
        
    },

}

/************************  Attack Tab ************************/
Tabs.Attack = {
  tabOrder: 999997,
  tabLabel: 'Attack',
  myDiv: null,
  tileTypes:{0:"Bog",10:"Grassland",11:"Lake",20:"Woods",30:"Hills",40:"Mountain",50:"Plain",51:"City",52:"Ruin",53:"Misted City",54:"Dark Forest"},


    init: function(div){
    	var t = Tabs.Attack;
        t.myDiv = div;
        unsafeWindow.RemoveAtkQueue = t.RemoveQueue;

      	var m = '<DIV id=pbReinfMain class=pbStat>ATTACK (TO CREST BARB/PLAYER)</div><TABLE id=pireinforce width=100% height=0% class=pbTab><TR align="center"><BR>';
      	m +='<DIV align=center><INPUT class="buttonDash_'+ (AtkOptions.Running?'ON':'OFF') +'" id=AttackToggle type=submit value="'+translate("Attack")+' = '+ (AtkOptions.Running?'ON':'OFF')+'">&nbsp Rallypoint options in options tab!</div>';
      	m += '<TABLE id=pbReinf width=95% height=0% class=pbTab><TR align="left">';
      	m += '<TD width="75px"><B>From City: </b></td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=pbAcityFrom></span></div></td>';
      	m += '<TD width="60px"><B>Target:</b></td><TD>X:<INPUT id=targetX type=text size=3>&nbsp&nbspY:<INPUT id=targetY type=text size=3></td></table>';
    	  m += '<TABLE id=pbMarch width=100% height=0% class=pbTab><TR align="center"><TR><TR>';
        for (i=1;i<=4;i++) m += '<TD rowspan="3"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_50.jpg?6545"></td><TD>'+ unsafeWindow.unitnamedesctranslated["unt"+i][0]+'</td>';
      	m+='</tr><TR>';
      	for (i=1;i<=4;i++) m += '<TD><SPAN id=unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=1;i<=4;i++) m += '<TD><INPUT id=Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';   	
      	for (i=5;i<=8;i++) m += '<TD rowspan="3"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD>'+ unsafeWindow.unitnamedesctranslated["unt"+i][0]+'</td>';
      	m+='</tr><TR>';
      	for (i=5;i<=8;i++) m += '<TD><SPAN id=unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=5;i<=8;i++) m += '<TD><INPUT id=Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';
      	for (i=9;i<=12;i++) m += '<TD rowspan="3"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD>'+ unsafeWindow.unitnamedesctranslated["unt"+i][0]+'</td>';
      	m+='</tr><TR>';
      	for (i=9;i<=12;i++) m += '<TD><SPAN id=unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=9;i<=12;i++) m += '<TD><INPUT id=Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';
        for (i=13;i<=17;i++) m += '<TD rowspan="3"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD>'+ unsafeWindow.unitnamedesctranslated["unt"+i][0]+'</td>';
      	m+='</tr><TR>';
      	for (i=13;i<=17;i++) m += '<TD><SPAN id=unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=13;i<=17;i++) m += '<TD><INPUT id=Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';

  	    m += '</table><BR><TABLE id=pbReinfETA width=10% height=0% align="center" class=pbTab>';
  	    m += '<TR align="center"><TD><a class="button20" id=AtkaddToQueue><span>Save Attack</span></a></td></tr></table>';
  	    m+= '<BR><DIV id=pbReinfMain class=pbStat>Saved Marches</div><BR><BR><DIV id=AtkQueue></div>';
      
      	t.myDiv.innerHTML = m;

      	t.from = new CdispCityPicker ('pbAfrom', document.getElementById('pbAcityFrom'), true, t.ClickCitySelect, 0); 
		document.getElementById('AttackToggle').addEventListener('click', function(){t.toggleAttackState()} , false);     
      	for (i=1;i<=17;i++) document.getElementById('unit'+i).innerHTML = addCommas(Seed.units["city" + t.from.city.id]["unt"+i]);
      	for (i=1;i<=17;i++)  document.getElementById('Max'+i).addEventListener('click', function(){t.CalcMax(this.id)}, false);
		    document.getElementById('AtkaddToQueue').addEventListener ('click', t.GetCoords,false); 	
        	t.PaintQueue();
    },

    toggleAttackState: function() {
        var t = Tabs.Attack;
            if (AtkOptions.Running == true) {
                AtkOptions.Running = false;
                if (document.getElementById('AttackToggle')) {document.getElementById('AttackToggle').value = "Attack = OFF";document.getElementById('AttackToggle').setAttribute("class", "buttonDash_OFF");}
                if (document.getElementById('AttackToggleD')) {document.getElementById('AttackToggleD').value = "Attack = OFF";document.getElementById('AttackToggleD').setAttribute("class", "buttonDash_OFF");}
                ClearMarchQueue("Attack");
                saveAtkOptions();
            } else {
                AtkOptions.Running = true;
                if (document.getElementById('AttackToggle')) {document.getElementById('AttackToggle').value = "Attack = ON";document.getElementById('AttackToggle').setAttribute("class", "buttonDash_ON");}
                if (document.getElementById('AttackToggleD')) {document.getElementById('AttackToggleD').value = "Attack = ON";document.getElementById('AttackToggleD').setAttribute("class", "buttonDash_ON");}
                saveAtkOptions();
            }
    },

   	GetCoords : function (){
	    var t= Tabs.Attack;
	    var targetName = "";
	    var targetCityName = "";
	    var tileLevel =0;
	    var total=0;
	    targetX = document.getElementById('targetX').value;
	    targetY = document.getElementById('targetY').value;
	    if (targetX =="" || targetY=="") {alert("Please enter coords...");return;}
	    for (i=1;i<=17;i++) total += parseInt(document.getElementById('Unt'+i).value);
	    if (total == 0) {alert("You got to send a least one troop...");return;}
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.blocks = "bl_" + targetX + "_bt_" + targetY;
	     
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
    				userId = rslt.data["l_"+targetX+"_t_"+targetY].tileUserId;    				
    				if (rslt.data["l_"+targetX+"_t_"+targetY].cityName) targetCityName = rslt.data["l_"+targetX+"_t_"+targetY].cityName;
    				 else targetCityName = "---";			
    				if (userId != null && userId != 0) targetName = rslt.userInfo["u" + userId]["n"];
        			for (i=1;i<=Seed.cities.length;i++) if (Seed.cities[i-1][0] == t.from.city.id) cityNumber = i;
        			AtkOptions[cityNumber].push ({
        				what: 			"Attack",
        				city: 			t.from.city.id,
        				action: 		4,
        				targetX: 		targetX,
        				targetY: 		targetY,
        				targetCityName: targetCityName,
        				targetName: 	targetName,
        				tileLevel: 		rslt.data["l_"+targetX+"_t_"+targetY].tileLevel,
        				tileType: 		rslt.data["l_"+targetX+"_t_"+targetY].tileType,
        				1: 				document.getElementById('Unt1').value,
        				2: 				document.getElementById('Unt2').value,
        				3: 				document.getElementById('Unt3').value,
        				4: 				document.getElementById('Unt4').value,
        				5: 				document.getElementById('Unt5').value,
        				6: 				document.getElementById('Unt6').value,
        				7: 				document.getElementById('Unt7').value,
        				8: 				document.getElementById('Unt8').value,
        				9: 				document.getElementById('Unt9').value,
        				10: 			document.getElementById('Unt10').value,
        				11: 			document.getElementById('Unt11').value,
        				12: 			document.getElementById('Unt12').value,
        				13: 			document.getElementById('Unt13').value,
        				14: 			document.getElementById('Unt14').value,
        				15: 			document.getElementById('Unt15').value,
                16: 			document.getElementById('Unt16').value,
                17: 			document.getElementById('Unt17').value,
        				r1:             0,
            			r2:             0,
            			r3:             0,
            			r4:             0,
            			r5:             0,
           				gold:           0,
        			});
					saveAtkOptions();
					t.PaintQueue();
					for(i=1;i<=17;i++) document.getElementById('Unt'+i).value=0;
					document.getElementById('targetX').value="";
					document.getElementById('targetY').value="";
        		}
      		},
    	});
	},

	PaintQueue : function (){
	    var t= Tabs.Attack;
	    document.getElementById('AtkQueue').innerHTML = '<TABLE id=AtkShowQ class=pbStat align="center" width=80%></table>';
	    for (var i=1;i<=Seed.cities.length;i++) {
	    	CityQueue = AtkOptions[i];
	    	for (var y=0;y<CityQueue.length;y++) {
	    		tag = "city"+i+"item"+y;	
	    		t._addTab(CityQueue[y],tag,i,y);
	    	}
	    }
	    t._addTabHeader();
	 },

	 _addTab: function(action,k,city,item){
	    var t = Tabs.Attack;

	    for (postcity in Seed.cities) if (Seed.cities[postcity][0] == action.city) logcity = Seed.cities[postcity][1];
	    var total = 0;
		var info = "";
		var type="";
		for (i=1;i<=17;i++) total += parseInt(action[i]);
		switch (parseInt(action.tileType)) {
			case 0: info = "Bog";break;
			case 10: info = "Grassland";break;
			case 11: info = "Lake";break;
			case 20: info = "Woods";break;
			case 30: info = "Hills";break;
			case 40: info = "Mountain";break;
			case 50: info = "Plain";break;
			case 51: 
				if (action.targetCityName == null && !action.misted) info = "Barb Camp";
					else info = action.targetName;
				break;
			case 53: info = "Misted City";break;
		}
	    var row = document.getElementById('AtkShowQ').insertRow(0);
	    row.vAlign = 'top';
	    row.style.color = "black";
	    row.insertCell(0).innerHTML = '<A onclick="RemoveAtkQueue('+ city +','+ item +')"><img src=""/>';	  
	    row.insertCell(1).innerHTML = logcity;
	    row.insertCell(2).innerHTML = coordLink(parseInt(action.targetX),parseInt(action.targetY));
	    row.insertCell(3).innerHTML = info;
	    row.insertCell(4).innerHTML = action.targetCityName;
	    row.insertCell(5).innerHTML = action.tileLevel;
	    row.insertCell(6).innerHTML = addCommas(total);
	    row.insertCell(7).innerHTML = '<a class="button20" id="Details' + k + '"><span>Details</span></a>';
	    document.getElementById('Details' + k).addEventListener('click', function(){t.DetailsPop(action,logcity,info);}, false);
	},

	_addTabHeader: function() {
	    var t = Tabs.Attack;
	    var row = document.getElementById('AtkShowQ').insertRow(0);
	    row.vAlign = 'top';
	    row.style.color = "black";
	    row.insertCell(0).innerHTML = "&nbsp";
	    row.insertCell(1).innerHTML = "From City";
	    row.insertCell(2).innerHTML = "Coords";
	    row.insertCell(3).innerHTML = "Target Name";
	    row.insertCell(4).innerHTML = "City";
	    row.insertCell(5).innerHTML = "Level";
	    row.insertCell(6).innerHTML = "Troops";
	    row.insertCell(7).innerHTML = "Details";
	},

	DetailsPop : function (action,logcity,info){
		var t = Tabs.Attack;
		var m = '<TABLE id=pbMarch width=100% height=0% class=pbTab>';
	    m+= '<TR><TD width="50px"></td><TD>From city: ' + logcity + '</td></tr>';
	    m+= '<TR><TD width="50px"></td><TD>Target: ' + info + '</td></tr>';
	    m+= '<TR><TD width="50px"></td><TD>City: ' + action.targetCityName + '</td></tr>';
	    m+= '<TR><TD width="50px"></td><TD>Level: ' + action.tileLevel + '</td></tr>';
	    m+= '<TR><TD width="50px"></td><TD>Coords: ' +  coordLink(parseInt(action.targetX),parseInt(action.targetY)) + '</td></tr></table><BR>';
	    m += '<TABLE id=pbMarch width=100% height=0% class=pbTab><TR>';
	    for (i=1;i<=4;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
	    m+='</tr><TR>'; 
	    for (i=5;i<=8;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
	    m+='</tr><TR>'; 
	    for (i=9;i<=12;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
	    m+='</tr><TR>';
	    for (i=13;i<=17;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
	    m+='</tr></table><BR>'; 
	    var pop = new pbPopup ('giftHelp', 0, 0, 550, 410, true);
	    pop.centerMe (mainPop.getMainDiv());  
	    pop.getMainDiv().innerHTML = m;
	    pop.getTopDiv().innerHTML = '<CENTER><B>Saved March info</center>';
	    pop.show (true);
	  },
   
    ClickCitySelect: function(city){
                var t = Tabs.Attack;  
                for (i=1;i<=17;i++) document.getElementById('unit'+i).innerHTML = addCommas(Seed.units["city" + t.from.city.id]["unt"+i]);
    },

    RemoveQueue: function(city,item){
        var t = Tabs.Attack;
        AtkOptions[city].splice(item,1);
        t.PaintQueue();
    	saveAtkOptions();
    },

    doMarch: function(cityID,i){
        var t = Tabs.Attack;
        for (var y=0;y<AtkOptions[i+1].length;y++) if (AtkOptions[i+1][y]["city"] == cityID) MarchQueue[i+1].push(AtkOptions[i+1][y]);
    },

    show: function(){
        var t = Tabs.Attack;
    },
    hide: function(){
        var t = Tabs.Attack;
    },
    onUnload: function(){
    },
}




/************************  Dark Forest Tab ************************/
Tabs.DF = {
  tabOrder: 999990,
  tabLabel: 'Dark Forest',
  myDiv: null,
  cityID: null,
  rallypointlevel:null,
  maxsend:0,
  knt:null,
  DFArray:{},


    init: function(div){
    	var t = Tabs.DF;
        t.myDiv = div;

      	var m= '<DIV id=pbReinfMain class=pbStat>AUTOMATED FOREST FUNCTION</div><BR>';
      	m+='<TD><INPUT class="buttonDash_'+ (DFOptions.Running?'ON':'OFF') +'" id=AttSearch type=submit value="'+translate("Auto DF")+' = '+ (DFOptions.Running?'ON':'OFF')+'"></td>';
      	m+='&nbsp<INPUT id=pbDFShow type=submit class=pbButton value="Show DF\'s">&nbsp<INPUT id=pbReset type=submit class=pbButton value="Re-search">';
      	m+='&nbsp Radius 45 - Search every 20min - rallypoint options in options tab!';
      	m+='<DIV id=DFStats text-align=center></div>';
      	m+='<DIV id=pbReinfMain class=pbStat>DF SELECT LEVELS</div><BR>';

      	m+='<TABLE width=100%>';
      	for (i=0;i<Seed.cities.length;i++) {
      		m+='<TR><TD>' + Seed.cities[i]["1"] + '</td>';
      		for (y=1;y<=10;y++) m+='<TD class=DFLevelopt><INPUT id=DFcity'+i+'level'+y+' type=checkbox unchecked=true>Lvl:'+y+'</td>';
      	}
      	m+='</table>';
      	m += '<DIV id=pbReinfMain class=pbStat>DF SELECT TROOPS</div>';
      	m += '<B>For a march with max. amount of troops for the rallypoint, enter MAX in the box.</b><BR>';
      	m+='<TABLE width=100%><TR><TD></td>';
      	for(var i=1;i<=17; i++) m+='<TD>'+unsafeWindow.unitcost['unt'+i][0]+'</td>';
      	for(i=1;i<=10;i++){
        	m += '</tr><TR><TD>Level '+i+': </td>';
         	for(var j=1; j<=17; j++) m += '<TD class=DFTroopOpt><INPUT id="DFlevel'+i+'troop'+j+'" type=text size=4 maxlength=6 value="'+DFOptions.Troops[i][j]+'" /></td>';
     	}
     	m+='</tr></table>';

      	
      	t.myDiv.innerHTML = m;

      	for(i=0;i<Seed.cities.length;i++) for(w=1;w<=10;w++)document.getElementById('DFcity'+i+'level'+w).checked = DFOptions.Levels[i+1][w];
      	document.getElementById('pbReset').addEventListener('click', t.ResetDFData, false);
      	var element_class = document.getElementsByClassName('DFLevelopt');
    	for (k=0;k<element_class.length;k++) element_class[k].addEventListener('click', t.saveLevelOptions , false);
    	var element_class = document.getElementsByClassName('DFTroopOpt');
    	for (k=0;k<element_class.length;k++) element_class[k].addEventListener('change', t.saveTroopOptions , false);
    	document.getElementById('AttSearch').addEventListener('click', function(){t.toggleDFState()} , false);
    	document.getElementById('pbDFShow').addEventListener('click', function(){t.ShowDFArray()} , false);
    	
    	var now = unixTime();
    	document.getElementById('DFStats').innerHTML = "Last Search done at: " + FullDateTime(DFOptions.LastSearch) + " found " + DFOptions.DFFound + " Dark Forests.";
		if ((DFOptions.LastSearch + (20 * 60 * 1000)) < now && DFOptions.Running) t.ResetDFData(); 
		else {
			for (i=0;i<Seed.cities.length;i++){
	    		var helpArray = JSON2.parse(GM_getValue('DarkForest_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(),"[]"));
	    		t.DFArray[i] = [];
	    		if (helpArray) t.DFArray[i] = helpArray.sort(function sortBarbs(a,b) {a = a['dist'];b = b['dist'];return a == b ? 0 : (a < b ? -1 : 1);});
			}
		}
	},

	ShowDFArray: function(){
		var t = Tabs.DF;
		var m = '<TABLE id=pbDF width=80% height=0% class=pbTab>';
		for (i=0;i<Seed.cities.length;i++) {
			if (t.DFArray[i].length>0){
				m+= '<TR><TD colspan=5 style=\'background: #335577;\' align=center><B><FONT color=white>' + Seed.cities[i][1] +': </font></b></td></tr>';
				for (var k in t.DFArray[i]) if (t.DFArray[i][k].dist) {
					if (t.DFArray[i][k].Level>=1 && t.DFArray[i][k].Level<=3) var Tlevel = 1;
					if (t.DFArray[i][k].Level>=4 && t.DFArray[i][k].Level<=6) var Tlevel = 4;
					if (t.DFArray[i][k].Level>=7) var Tlevel = 7;
					m+='<TR><TD>' + coordLink(t.DFArray[i][k].X,t.DFArray[i][k].Y) + '</td><TD width=50px><img width=50px src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/buildings/boss_lvl'+Tlevel+'.png"></td><TD>Lvl.: '+t.DFArray[i][k].Level+'</td><TD>Dist.: '+t.DFArray[i][k].dist+'</td></tr>';
				}
			}
		}
	    var pop = new pbPopup ('DFArray', 0, 0, 550, 410, true);
	    pop.centerMe (mainPop.getMainDiv());  
	    pop.getMainDiv().innerHTML = '<DIV style="width:550px;max-width:550px;height:410px;max-height:410px;overflow:auto">' +m+ '</div>';
	    pop.getTopDiv().innerHTML = '<CENTER><B>DF\'s Found</center>';
	    pop.show (true);

	},

    toggleDFState: function(obj){
		    var t = Tabs.DF;
		    if (DFOptions.Running == true) {
		        DFOptions.Running = false;
		        if (document.getElementById('AttSearch')) {document.getElementById('AttSearch').value = "Auto DF = OFF";document.getElementById('AttSearch').setAttribute("class", "buttonDash_OFF");}
		        if (document.getElementById('AutoDfToggle')) {document.getElementById('AutoDfToggle').value = "Auto DF = OFF";document.getElementById('AutoDfToggle').setAttribute("class", "buttonDash_OFF");}
		       	ClearMarchQueue("DF");
		        saveDFOptions();
		    } else {
		        DFOptions.Running = true;
		        if (document.getElementById('AttSearch')) {document.getElementById('AttSearch').value = "Auto DF = ON";document.getElementById('AttSearch').setAttribute("class", "buttonDash_ON");}
		        if (document.getElementById('AutoDfToggle')) {document.getElementById('AutoDfToggle').value = "Auto DF = ON";document.getElementById('AutoDfToggle').setAttribute("class", "buttonDash_ON");}
		        if ((DFOptions.LastSearch + (20 * 60)) < now) t.ResetDFData(); 
		        saveDFOptions();
		    }
  	},

    saveLevelOptions : function(){
        for(i=0;i<Seed.cities.length;i++){
            DFOptions.Levels[i+1][0]=false;
            for (w=1;w<=10;w++){
                var ele = document.getElementById('DFcity'+i+'level'+w);
                DFOptions.Levels[i+1][w]=ele.checked;
                if (ele.checked) DFOptions.Levels[i+1][0]=true;
            }        
        }
        saveDFOptions();
    },

    saveTroopOptions : function(){
        for(i=1;i<=10;i++) for (w=1;w<=17;w++) DFOptions.Troops[i][w] = document.getElementById('DFlevel'+i+'troop'+w).value;  
        saveDFOptions();
    },

    doMarch : function(cityID,i){
    	var t = Tabs.DF;
    	var now = unixTime();
    	if ((DFOptions.LastSearch + (40 * 60)) < now) {t.ResetDFData();return false;}  		
    	if (t.DFArray[i].length==0) return false;
    	var Level = parseInt(t.DFArray[i][0].Level);
    	if (!DFOptions.Levels[i+1][Level]) return;
    	var troops = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    	for (y=1;y<=17;y++){
    		if (DFOptions.Troops[Level][y] == "MAX") {
    			var total=0;
    			for (var yy=1;yy<=17;yy++) if (y!=yy) total+=parseInt(DFOptions.Troops[Level][yy]);
    			troops[y] =  t.CalcMax(cityID,y) - total;
    		}
    		else troops[y] = DFOptions.Troops[Level][y];
    	}
    	MarchQueue[i+1].push ({
    		what: 			"DF",
			city: 			cityID,
			action: 		4,
			targetX: 		t.DFArray[i][0].X,
			targetY: 		t.DFArray[i][0].Y,
			1: 				troops[1],
			2: 				troops[2],
			3: 				troops[3],
			4: 				troops[4],
			5: 				troops[5],
			6: 				troops[6],
			7: 				troops[7],
			8: 				troops[8],
			9: 				troops[9],
			10: 			troops[10],
			11: 			troops[11],
			12: 			troops[12],
			13: 			troops[13],
			14: 			troops[14],
			15: 			troops[15],
      16: 			troops[16],
      17: 			troops[17],
        });
        t.DFArray[i].splice(0,1);
        GM_setValue('DarkForest_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(), JSON2.stringify(t.DFArray[i]));
        return true;
    },

    ResetDFData: function(){
    	var t = Tabs.DF;
    	for (i=0;i<Seed.cities.length;i++) GM_deleteValue('DarkForest_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(),"[]")
    	var ToSearch = [];
    	var now = unixTime();
    	for (i=0;i<Seed.cities.length;i++){
    		AllEmpty = true;
    		t.DFArray[i] = [];
    		for (var y=1;y<=10;y++) if (DFOptions.Levels[i+1][y]) AllEmpty = false;
    		if (!AllEmpty) ToSearch.push(i);
    	}
    	if (ToSearch.length > 0){
    		DFOptions.LastSearch = now;
    		DFOptions.DFFound = 0;
    		saveDFOptions();
    		document.getElementById('DFStats').innerHTML='Searching: <PROGRESS id=searchProgress value="0" max="'+ ToSearch.length +'"></progress>';
    		for (i=0;i<ToSearch.length;i++) {
    			X = parseInt(Seed.cities[ToSearch[i]][2]);
              	Y = parseInt(Seed.cities[ToSearch[i]][3]);
				setTimeout(t.MakeBlocks,((i+1)*6500),X,Y,(ToSearch[i]+1),(i+1),ToSearch.length);
    		}
    	}	
    },

    MakeBlocks:function(getX,getY,city,i,length){
    	var t = Tabs.DF;
    	var blocks = [];
		var xx=0;
		var yy=0;
		for (x=(getX-30);x<=(getX+30);x+=5) {
		   for (y=(getY-30);y<=(getY+30);y+=5) {
				xx=x;
				yy=y;
				if (x>750) xx-=750;
				if (y>750) yy-=750;
				if (x<0) xx+=750;
				if (y<0) yy+=750;
				blocks.push ("bl_" + xx + "_bt_" + yy);
			}
		}
		t.doSearch(blocks,getX,getY,city,i,length)
    },

    doSearch:function (pass,xx,yy,city,i,length){
    	var t = Tabs.DF;
		var mapDat = [];
    var mapDat2 = [];
      var testg =  parseInt(pass.length/20);
     // var testh = 0;
      for (var gg = 0; gg <= testg; gg++){
      setTimeout (function(){
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
       
      var pass2 = pass.splice(0,20);
    	params.blocks = pass2; 
	     
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			if (rslt.data == []) alert("MAP ERROR");
        			if (i < length) document.getElementById('searchProgress').value = i;
              
        			else document.getElementById('DFStats').innerHTML = "";
        			for (y in rslt.data) {
        				if (rslt.data[y].tileType == 54 && DFOptions.Levels[city][parseInt(rslt.data[y].tileLevel)]) {
        					var tileX = parseInt(rslt.data[y].xCoord);
        					var tileY = parseInt(rslt.data[y].yCoord);
							var Level = parseInt(rslt.data[y].tileLevel);
							var dist = distance(xx, yy, tileX, tileY);
        					mapDat.push({X:tileX,Y:tileY,Level:Level,dist:dist});
        					DFOptions.DFFound++;
        					saveDFOptions();
                  
                  if (gg=testg){
                    GM_setValue('DarkForest_' + Seed.player['name'] + '_city_' + city + '_' + getServerId(), JSON2.stringify(mapDat));
					var helpArray = JSON2.parse(GM_getValue('DarkForest_' + Seed.player['name'] + '_city_' + city + '_' + getServerId(),"[]"));
					if (helpArray) {
          mapDat2.concat(helpArray);
				   	 t.DFArray[(city-1)] = mapDat2.sort(function sortBarbs(a,b) {a = a['dist'];b = b['dist'];return a == b ? 0 : (a < b ? -1 : 1);});         
                  	if (i < length) document.getElementById('searchProgress').value = i;
        			else document.getElementById('DFStats').innerHTML = "Last Search done at: " + FullDateTime(DFOptions.LastSearch) + " found " + DFOptions.DFFound + "Dark Forests.";
              }
        	       }
        				}
        			}        			        			
						}
      		},
    	});
      
      },500)
      }
     
	},
  
    CalcMax : function (city,troop){
    	var t = Tabs.DF;
    	var maxsend = 0;
    	var rallypointlevel = 0;	
    	for (var o in Seed.buildings["city" + city]){
		    var buildingType = parseInt(Seed.buildings["city" + city][o][0]);
		    var buildingLevel = parseInt(Seed.buildings["city" + city][o][1]);
		    if (buildingType == 12) rallypointlevel=parseInt(buildingLevel);
		}
    	if(rallypointlevel == 11) rallypointlevel = 15;
		if(rallypointlevel == 12) rallypointlevel = 20;
    	maxsend = (rallypointlevel * 10000);
		if (Seed.cityData.city[city].isPrestigeCity) {
    		switch(parseInt(Seed.cityData.city[city].prestigeInfo.prestigeLevel)){
    			case 1: maxsend = Math.round(maxsend * 1.50);break;
    			case 2: maxsend = Math.round(maxsend * 1.60);break;
    			case 3: maxsend = Math.round(maxsend * 1.65);break;
          case 4: maxsend = Math.round(maxsend * 1.70);break;
case 5: maxsend = Math.round(maxsend * 1.75);break;
case 6: maxsend = Math.round(maxsend * 1.80);break;
    		}
    	}
    	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
    	//maxsend = maxsend + ((maxsend / 100) * TR);
    	maxsend+=Math.round(maxsend * (TR / 100));
    	if (maxsend > Seed.units["city" + city]["unt"+troop]) maxsend=0;
    	return maxsend; 
    },

	getKnights : function(){
	   var t = Tabs.DF;
	   t.knt = new Array();
	   for (k in Seed.knights['city' + t.from.city.id]){
	           if (Seed.knights['city' + t.from.city.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.from.city.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["politicsKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["combatKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["intelligenceKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"]){
	               t.knt.push ({
	                   Name:   Seed.knights['city' + t.from.city.id][k]["knightName"],
	                   Combat:    parseInt(Seed.knights['city' + t.from.city.id][k]["combat"]),
	                   ID:        Seed.knights['city' + t.from.city.id][k]["knightId"],
	               });
	           }
	   }
	   t.knt = t.knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
	 
	},

    show: function(){var t = Tabs.DF;},
    hide: function(){var t = Tabs.DF;},
    onUnload: function(){},
}
/********* merc  **/
 Tabs.merc={
  
  tabOrder : 999991,
 tabLabel : 'Merc',
  myDiv: null,
  cityID: null,
  rallypointlevel:null,
  maxsend:0,
  knt:null,
  mercArray:{},


    init: function(div){
    	var t = Tabs.merc;
        t.myDiv = div;

      	var m= '<DIV id=pbReinfMain class=pbStat>AUTOMATED MERC FUNCTION</div><BR>';
      	m+='<TD><INPUT class="buttonDash_'+ (mercOptions.Running?'ON':'OFF') +'" id=mercAttsearch type=submit value="'+translate("Auto merc")+' = '+ (mercOptions.Running?'ON':'OFF')+'"></td>';
      	m+='&nbsp<INPUT id=pbmercShow type=submit class=pbButton value="Show merc\'s">&nbsp<INPUT id=pbResetmerc type=submit class=pbButton value="Re-search">';
      	m+='&nbsp Radius 45 - Search every 20min - rallypoint options in options tab!';
      	m+='<DIV id=mercStats text-align=center></div>';
      	m+='<DIV id=pbReinfMain class=pbStat>SELECT CITIES</div><BR>';
        
      	m+='<TABLE width=100%>';
      	for (i=0;i<Seed.cities.length;i++) {
      		m+='<TD>' + Seed.cities[i]["1"] + '</td>';
      		m+='<TD class=mercLevelopt><INPUT id=merccity'+i+'level'+1+' type=checkbox unchecked=true>';
          
      	}
      	m+='</table>';
      	m += '<DIV id=pbReinfMain class=pbStat>merc SELECT TROOPS</div>';
      	m += '<B>For a march with max. amount of troops for the rallypoint, enter MAX in the box.</b><BR>';
      	m+='<TABLE width=100%><TR><TD></td>';
      	for(var i=1;i<=8; i++) m+='<TD>'+unsafeWindow.unitcost['unt'+i][0]+'</td>';
      	
        	m += '</tr><TR><TD>Troops: </td>';
         	for(var j=1; j<=8; j++) m += '<TD class=mercTroopOpt><INPUT id="merclevel'+1+'troop'+j+'" type=text size=4 maxlength=6 value="'+mercOptions.Troops[1][j]+'" /></td>';
     	    
     	m+='</tr></table>';
      m+='<TABLE width=100%><TR><TD></td>';
      	for(var i=9;i<=17; i++) m+='<TD>'+unsafeWindow.unitcost['unt'+i][0]+'</td>';
      	
        	m += '</tr><TR><TD>Troops: </td>';
         	for(var j=9; j<=17; j++) m += '<TD class=mercTroopOpt><INPUT id="merclevel'+1+'troop'+j+'" type=text size=4 maxlength=6 value="'+mercOptions.Troops[1][j]+'" /></td>';
     	    
     	m+='</tr></table>';

      	
      	t.myDiv.innerHTML = m;

      	for(i=0;i<Seed.cities.length;i++) document.getElementById('merccity'+i+'level'+1).checked = mercOptions.Levels[i+1]["1"];
      	document.getElementById('pbResetmerc').addEventListener('click', t.ResetmercData, false);
      	var element_class = document.getElementsByClassName('mercLevelopt');
    	for (k=0;k<element_class.length;k++) element_class[k].addEventListener('click', t.saveLevelOptions , false);
    	var element_class = document.getElementsByClassName('mercTroopOpt');
    	for (k=0;k<element_class.length;k++) element_class[k].addEventListener('change', t.saveTroopOptions , false);
    	document.getElementById('mercAttsearch').addEventListener('click', function(){t.togglemercState()} , false);
    	document.getElementById('pbmercShow').addEventListener('click', function(){t.ShowmercArray()} , false);
    	
    	var now = unixTime();
    	document.getElementById('mercStats').innerHTML = "Last Search done at: " + FullDateTime(mercOptions.LastSearch) + " found " + mercOptions.mercFound + " merc.";
		if ((mercOptions.LastSearch + (20 * 60 * 1000)) < now && mercOptions.Running) t.ResetmercData(); 
		else {
			for (i=0;i<Seed.cities.length;i++){
	    		var helpArray = JSON2.parse(GM_getValue('DarkForest_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(),"[]"));
	    		t.mercArray[i] = [];
	    		if (helpArray) t.mercArray[i] = helpArray.sort(function sortBarbs(a,b) {a = a['dist'];b = b['dist'];return a == b ? 0 : (a < b ? -1 : 1);});
			}
		}
	},

	ShowmercArray: function(){
		var t = Tabs.merc;
		var m = '<TABLE id=pbmerc width=80% height=0% class=pbTab>';
		for (i=0;i<Seed.cities.length;i++) {
			if (t.mercArray[i].length>0){
				m+= '<TR><TD colspan=5 style=\'background: #335577;\' align=center><B><FONT color=white>' + Seed.cities[i][1] +': </font></b></td></tr>';
				for (var k in t.mercArray[i]) if (t.mercArray[i][k].dist) {
					if (t.mercArray[i][k].Level>=1 && t.mercArray[i][k].Level<=3) var Tlevel = 1;
					if (t.mercArray[i][k].Level>=4 && t.mercArray[i][k].Level<=6) var Tlevel = 4;
					if (t.mercArray[i][k].Level>=7) var Tlevel = 7;
					m+='<TR><TD>' + coordLink(t.mercArray[i][k].X,t.mercArray[i][k].Y) + '</td><TD width=50px><img width=50px src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/buildings/mercenary_hideout.png"></td><TD>Lvl.: '+t.mercArray[i][k].Level+'</td><TD>Dist.: '+t.mercArray[i][k].dist+'</td></tr>';
				}
			}
		}
	    var pop = new pbPopup ('mercArray', 0, 0, 550, 410, true);
	    pop.centerMe (mainPop.getMainDiv());  
	    pop.getMainDiv().innerHTML = '<DIV style="width:550px;max-width:550px;height:410px;max-height:410px;overflow:auto">' +m+ '</div>';
	    pop.getTopDiv().innerHTML = '<CENTER><B>merc\'s Found</center>';
	    pop.show (true);

	},

    togglemercState: function(obj){
		    var t = Tabs.merc;
		    if (mercOptions.Running == true) {
		        mercOptions.Running = false;
		        if (document.getElementById('mercAttsearch')) {document.getElementById('mercAttsearch').value = "Auto merc = OFF";document.getElementById('mercAttsearch').setAttribute("class", "buttonDash_OFF");}
		        if (document.getElementById('AutomercToggle')) {document.getElementById('AutomercToggle').value = "Auto merc = OFF";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_OFF");}
		       	ClearMarchQueue("merc");
		        savemercOptions();
		    } else {
		        mercOptions.Running = true;
		        if (document.getElementById('mercAttsearch')) {document.getElementById('mercAttsearch').value = "Auto merc = ON";document.getElementById('mercAttsearch').setAttribute("class", "buttonDash_ON");}
		        if (document.getElementById('AutomercToggle')) {document.getElementById('AutomercToggle').value = "Auto merc = ON";document.getElementById('AutomercToggle').setAttribute("class", "buttonDash_ON");}
		        if ((mercOptions.LastSearch + (20 * 60)) < now) t.ResetmercData(); 
		        savemercOptions();
		    }
  	},

    saveLevelOptions : function(){
        for(i=0;i<Seed.cities.length;i++){
            mercOptions.Levels[i+1][0]=true;
            for (w=1;w<=1;w++){
                var ele = document.getElementById('merccity'+i+'level'+1);
                mercOptions.Levels[i+1][1]=ele.checked;
                if (ele.checked) mercOptions.Levels[i+1][0]=true;
            }        
        }
        savemercOptions();
    },

    saveTroopOptions : function(){
        for(i=1;i<=10;i++) for (w=1;w<=17;w++) mercOptions.Troops[i][w] = document.getElementById('merclevel'+1+'troop'+w).value;  
        savemercOptions();
    },

    doMarch : function(cityID,i){
    	var t = Tabs.merc;
    	var now = unixTime();
    	if ((mercOptions.LastSearch + (20 * 60)) < now) {t.ResetmercData();return false;}  		
    	if (t.mercArray[i].length==0) return false;
    	var Level = parseInt(t.mercArray[i][0].Level);
    	//if (!mercOptions.Levels[i+1][Level]) return;
    	var troops = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    	for (y=1;y<=17;y++){
    		if (mercOptions.Troops[Level][y] == "MAX") {
    			var total=0;
    			for (var yy=1;yy<=17;yy++) if (y!=yy) total+=parseInt(mercOptions.Troops[Level][yy]);
    			troops[y] =  t.CalcMax(cityID,y) - total;
    		}
    		else troops[y] = mercOptions.Troops[Level][y];
    	}
    	MarchQueue[i+1].push ({
    		what: 			"merc",
			city: 			cityID,
			action: 		4,
			targetX: 		t.mercArray[i][0].X,
			targetY: 		t.mercArray[i][0].Y,
			1: 				troops[1],
			2: 				troops[2],
			3: 				troops[3],
			4: 				troops[4],
			5: 				troops[5],
			6: 				troops[6],
			7: 				troops[7],
			8: 				troops[8],
			9: 				troops[9],
			10: 			troops[10],
			11: 			troops[11],
			12: 			troops[12],
			13: 			troops[13],
			14: 			troops[14],
			15: 			troops[15],
      16:       troops[16],
      17:       troops[17],
        });
        t.mercArray[i].splice(0,1);
        GM_setValue('Farms_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(), JSON2.stringify(t.mercArray[i]));
        return true; //GM_setValue('Farms_'
    },

    ResetmercData: function(){
    	var t = Tabs.merc;
    	for (i=0;i<Seed.cities.length;i++) GM_deleteValue('Farms_' + Seed.player['name'] + '_city_' + (i+1) + '_' + getServerId(),"[]")
    	var ToSearch = [];
    	var now = unixTime();
    	for (i=0;i<Seed.cities.length;i++){
    		AllEmpty = true;
    		t.mercArray[i] = [];
    		for (var y=1;y<=10;y++) if (mercOptions.Levels[i+1][y]) AllEmpty = false;
    		if (!AllEmpty) ToSearch.push(i);
    	}
    	if (ToSearch.length > 0){
    		mercOptions.LastSearch = now;
    		mercOptions.mercFound = 0;
    		savemercOptions();
    		document.getElementById('mercStats').innerHTML='Searching: <PROGRESS id=searchProgress value="0" max="'+ ToSearch.length +'"></progress>';
    		for (i=0;i<ToSearch.length;i++) {
    			X = parseInt(Seed.cities[ToSearch[i]][2]);
              	Y = parseInt(Seed.cities[ToSearch[i]][3]);
				setTimeout(t.MakeBlocks,((i+1)*6500),X,Y,(ToSearch[i]+1),(i+1),ToSearch.length);
    		}
    	}	
    },

    MakeBlocks:function(getX,getY,city,i,length){
    	var t = Tabs.merc;
    	var blocks = [];
		var xx=0;
		var yy=0;
		for (x=(getX-40);x<=(getX+40);x+=5) {
		   for (y=(getY-40);y<=(getY+40);y+=5) {
				xx=x;
				yy=y;
				if (x>750) xx-=750;
				if (y>750) yy-=750;
				if (x<0) xx+=750;
				if (y<0) yy+=750;
				blocks.push ("bl_" + xx + "_bt_" + yy);
			}
		}
		t.doSearch(blocks,getX,getY,city,i,length)
    },

    doSearch:function (pass,xx,yy,city,i,length){
    	var t = Tabs.merc;
		var mapDat = [];
    var mapDat2 = [];
      var testg =  parseInt(pass.length/20)+1;
     // var testh = 0;
      for (var gg = 0; gg <= testg; gg++){
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
       
      var pass2 = pass.splice(0,20);
    	params.blocks = pass2; 
	     
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			if (rslt.data == []) alert("MAP ERROR");
        			if (i < length) document.getElementById('searchProgress').value = i;
              
        			else document.getElementById('mercStats').innerHTML = "";
        			for (y in rslt.data) {
        				if (rslt.data[y].tileType == 55 ) {
        					var tileX = parseInt(rslt.data[y].xCoord);
        					var tileY = parseInt(rslt.data[y].yCoord);
							var Level = parseInt(rslt.data[y].tileLevel);
							var dist = distance(xx, yy, tileX, tileY);
        					mapDat.push({X:tileX,Y:tileY,Level:Level,dist:dist});
        					mercOptions.mercFound++;
        					savemercOptions();
                  if (gg=testg){
                    GM_setValue('merc_' + Seed.player['name'] + '_city_' + city + '_' + getServerId(), JSON2.stringify(mapDat));
					var helpArray = JSON2.parse(GM_getValue('merc_' + Seed.player['name'] + '_city_' + city + '_' + getServerId(),"[]"));
					if (helpArray){ 
          mapDat2.concat(helpArray);
				   	t.mercArray[(city-1)] = mapDat2.sort(function sortBarbs(a,b) {a = a['dist'];b = b['dist'];return a == b ? 0 : (a < b ? -1 : 1);});         
                  	if (i < length) document.getElementById('searchProgress').value = i;
        			else document.getElementById('mercStats').innerHTML = "Last Search done at: " + FullDateTime(mercOptions.LastSearch) + " found " + mercOptions.mercFound + "Mercs.";
        	        }
                  }
        				}
        			}        			        			
						}
      		},
    	});
      }
     
	},

    CalcMax : function (city,troop){
    	var t = Tabs.merc;
    	var maxsend = 0;
    	var rallypointlevel = 0;	
    	for (var o in Seed.buildings["city" + city]){
		    var buildingType = parseInt(Seed.buildings["city" + city][o][0]);
		    var buildingLevel = parseInt(Seed.buildings["city" + city][o][1]);
		    if (buildingType == 12) rallypointlevel=parseInt(buildingLevel);
		}
    	if(rallypointlevel == 11) rallypointlevel = 15;
		if(rallypointlevel == 12) rallypointlevel = 20;
    	maxsend = (rallypointlevel * 10000);
		if (Seed.cityData.city[city].isPrestigeCity) {
    		switch(parseInt(Seed.cityData.city[city].prestigeInfo.prestigeLevel)){
    			case 1: maxsend = Math.round(maxsend * 1.50);break;
    			case 2: maxsend = Math.round(maxsend * 1.60);break;
    			case 3: maxsend = Math.round(maxsend * 1.65);break;
          case 4: maxsend = Math.round(maxsend * 1.70);break;
case 5: maxsend = Math.round(maxsend * 1.75);break;
case 6: maxsend = Math.round(maxsend * 1.80);break;
    		}
    	}
    	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
    	//maxsend = maxsend + ((maxsend / 100) * TR);
    	maxsend+=Math.round(maxsend * (TR / 100));
    	if (maxsend > Seed.units["city" + city]["unt"+troop]) maxsend=0;
    	return maxsend; 
    },

	getKnights : function(){
	   var t = Tabs.merc;
	   t.knt = new Array();
	   for (k in Seed.knights['city' + t.from.city.id]){
	           if (Seed.knights['city' + t.from.city.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.from.city.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["politicsKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["combatKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["intelligenceKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"]){
	               t.knt.push ({
	                   Name:   Seed.knights['city' + t.from.city.id][k]["knightName"],
	                   Combat:    parseInt(Seed.knights['city' + t.from.city.id][k]["combat"]),
	                   ID:        Seed.knights['city' + t.from.city.id][k]["knightId"],
	               });
	           }
	   }
	   t.knt = t.knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
	 
	},

    show: function(){var t = Tabs.merc;},
    hide: function(){var t = Tabs.merc;},
    onUnload: function(){},
}
 /**************************** Inventory Tab ****************************************/
Tabs.Inventory = {
   myDiv: null,
   general: [],
   speedup: [],
   combat: [],
   tabLabel: 'Inventory',
   taborder: 999988,
   resources: [],
   chest: [],
   court: [],
   type: null,
   queue:[],
   isBusy:false,
   counter:0,
   max:0,
   city_holder : 0,
   
   init: function(div){
      var t = Tabs.Inventory;
      t.myDiv = div;
      
      var m = "<DIV class=pbStat>Inventory Tab</div>\
            <CENTER><span class=boldRed>***Use at own risk***</span></center>\
            <TABLE width=100% ><TR>\
            <TD width=50%><input type=submit id=pbinventory_general value='General' />\
               <input type=submit id=pbinventory_speedup value='Speedup' />\
               <input type=submit id=pbinventory_combat value='Combat' />\
               <input type=submit id=pbinventory_resources value='Resources' />\
               <input type=submit id=pbinventory_chest value='Chest' />\
               <input type=submit id=pbinventory_court value='Court' /></td>\
            <TD width=50% align=center ><input type=submit id=pbinventory_start value='Start' /></td>\
               </tr>\
            <TD><span id='pbinventory_cityselect'></span></td>\
            <TD><input type=checkbox id=pbinventory_useall />Use all by default</td>\
               </tr></table>\
            <DIV class=pbStat>Items</div>\
            <DIV id=pbinventory></div>\
            <DIV id=pbinventory_info></div>";
      t.myDiv.innerHTML = m;
      t.sort_Items();
      
      t.city = new CdispCityPicker ('pbinventory_city', document.getElementById('pbinventory_cityselect'), true, null);
      
      $("pbinventory_general").addEventListener('click', t.display_general, false);
      $("pbinventory_speedup").addEventListener('click', t.display_speedup, false);
      $("pbinventory_combat").addEventListener('click', t.display_combat, false);
      $("pbinventory_resources").addEventListener('click', t.display_resources, false);
      $("pbinventory_chest").addEventListener('click', t.display_chest, false);
      $("pbinventory_court").addEventListener('click', t.display_court, false);
      $("pbinventory_start").addEventListener('click', t.start, false);
      
      $("pbinventory_general").click();
      
      //Hack for ItemController
      t.ItemController = new CalterUwFunc("cm.MultiBuyUse.getNumberUsed", [[/(.|\n)*/i,'function (e) {return ItemController_hook();}']]);
      unsafeWindow.ItemController_hook = t.e_total;
   },
   
   sort_Items : function (){
      var t = Tabs.Inventory;
      for(var k in unsafeWindow.ksoItems){
         var item = unsafeWindow.ksoItems[k];
         if(item.count > 0 ){//&& item.usable){
            if(item.category == 1){
               t.general.push(item);
            }
            if(item.category == 2){
               t.speedup.push(item);
            }
            if(item.category == 3){
               t.combat.push(item);
            }
            if(item.category == 4){
               t.resources.push(item);
            }
            if(item.category == 5){
               t.chest.push(item);
            }
            if(item.category == 6){
               t.court.push(item);
            }
            
         }
      }
   },
   
   display_general : function (){
      var t = Tabs.Inventory;
      t.type = "general";
      var div = document.getElementById("pbinventory");
      var count = 0;
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td></tr><TR>";
      for (var k in t.general){
         var item = t.general[k];
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
         if(item.usable) {
         m += "<TD><input type=checkbox class='pbinv_general' data-ft='"+JSON.stringify(item)+"' /></td>";
         }
         else m+= "<TD></td>"
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
           if(item.usable) {
         m += "<TD><input type=text size=2 id='pb_inv_general_"+item.id+"' /></td>";
         }
         else m+= "<TD>  </td>"
         m += "<TD>"+item.count+"</td>";
         m += (count%3 == 2)?"</tr>":"";
         count++;
      }
      m += "</table>";
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   display_speedup : function (){
      var t = Tabs.Inventory;
      t.type = "speedup";
      var div = document.getElementById("pbinventory");
      var count = 0;
    
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td></tr><TR>";
      for (var k in t.speedup){
         var item = t.speedup[k];
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
         if(item.usable) {
         m += "<TD><input type=checkbox class='pbinv_speedup' data-ft='"+JSON.stringify(item)+"' /></td>";
         }
         else m+= "<TD></td>"
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
           if(item.usable) {
         m += "<TD><input type=text size=2 id='pb_inv_speedup_"+item.id+"' /></td>";
         }
         else m+= "<TD>  </td>"
         m += "<TD>"+item.count+"</td>";
         m += (count%3 == 2)?"</tr>":"";
         count++;
      }
      m += "</table>";
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   display_combat : function (){
      var t = Tabs.Inventory;
      t.type = "combat";
      var div = document.getElementById("pbinventory");
      var count = 0;
      var Atest = 0;
      var ctest = 0;
      var dtest = 0;
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD>might</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD>might</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD>might</td></tr><TR>";
      for (var k in t.combat){
         var item = t.combat[k];
         var btest = item.name.split(" ") ;
          if(isNaN(btest[0])) btest[0] =0;
         Atest= btest[0]*item.count;
         
        
            if (btest[2] == 'Troops') ctest = unsafeWindow.unitmight['unt'+1];
            if (btest[1] == 'Militiamen') ctest = unsafeWindow.unitmight['unt'+2];
            if (btest[1] == 'Scouts') ctest = unsafeWindow.unitmight['unt'+3];
            if (btest[1] == 'Pikeman') ctest = unsafeWindow.unitmight['unt'+4];
            if (btest[1] == 'Swordsman') ctest = unsafeWindow.unitmight['unt'+5];
            if (btest[1] == 'Archers') ctest = unsafeWindow.unitmight['unt'+6];
            if (btest[1] == 'Cavalry') ctest = unsafeWindow.unitmight['unt'+7];
            if (btest[1] == 'Heavy') ctest = unsafeWindow.unitmight['unt'+8];
            if (btest[2] == 'Wagons') ctest = unsafeWindow.unitmight['unt'+9];
            if (btest[1] == 'Ballistae') ctest = unsafeWindow.unitmight['unt'+10];
            if (btest[1] == 'Battering') ctest = unsafeWindow.unitmight['unt'+11];
            if (btest[1] == 'Catapults') ctest = unsafeWindow.unitmight['unt'+12];
            if (btest[1] == 'Bloodthorns') ctest = unsafeWindow.unitmight['unt'+13];
            if (btest[1] == 'Executioners') ctest = unsafeWindow.unitmight['unt'+14];
            if (btest[1] == 'Siege') ctest = unsafeWindow.unitmight['unt'+15];
            if (btest[1] == 'Flame') ctest = unsafeWindow.unitmight['unt'+16];
        
         
          
        
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
        if(item.usable) {
         m += "<TD><input type=checkbox class='pbinv_combat' data-ft='"+JSON.stringify(item)+"' /></td>";
         }
         else m+= "<TD></td>"
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
           if(item.usable) {
         m += "<TD><input type=text size=2 id='pb_inv_combat_"+item.id+"' /></td>";
         }
         else m+= "<TD>  </td>"
         m += "<TD>"+item.count+"</td><TD> "+addCommas(ctest*Atest)+"</td>";
         
         
         m += (count%3 == 2)?"</tr>":"";
         
          dtest +=ctest*Atest;
         count++;
      }
      m += "total might "+addCommas (dtest);
      m += "</table>";
      
      
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   display_resources : function (){
      var t = Tabs.Inventory;
      t.type = "resources";
      var div = document.getElementById("pbinventory");
      var count = 0;
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td></tr><TR>";
      for (var k in t.resources){
         var item = t.resources[k];
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
         if(item.usable) {
         m += "<TD><input type=checkbox class='pbinv_resources' data-ft='"+JSON.stringify(item)+"' /></td>";
         }
         else m+= "<TD></td>"
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
           if(item.usable) {
         m += "<TD><input type=text size=2 id='pb_inv_resources_"+item.id+"' /></td>";
         }
         else m+= "<TD>  </td>"
         m += "<TD>"+item.count+"</td>";
         m += (count%3 == 2)?"</tr>":"";
         count++;
      }
      m += "</table>";
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   display_chest : function (){
      var t = Tabs.Inventory;
      t.type = "chest";
      var div = document.getElementById("pbinventory");
      var count = 0;
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td></tr><TR>";
      for (var k in t.chest){
         var item = t.chest[k];
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
         m += "<TD><input type=checkbox class='pbinv_chest' data-ft='"+JSON.stringify(item)+"' /></td>";
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
         m += "<TD><input type=text size=2 id='pb_inv_chest_"+item.id+"' /></td>";
         m += "<TD>"+item.count+"</td>";
         m += (count%3 == 2)?"</tr>":"";
         count++;
      }
      m += "</table>";
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   display_court : function (){
      var t = Tabs.Inventory;
      t.type = "court";
      var div = document.getElementById("pbinventory");
      var count = 0;
      var m = "<TABLE>";
      m += "<TR><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='10px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td><TD width='20px'>&nbsp;</td><TD></td><TD>Name</td><TD>Use</td><TD>Count</td></tr><TR>";
      for (var k in t.court){
         var item = t.court[k];
         if(!item.name) continue;
         m += (count%3 == 0)?"<TR>":"<TD width='10px'>&nbsp;</td>";
         if(item.usable) {
         m += "<TD><input type=checkbox class='pbinv_court' data-ft='"+JSON.stringify(item)+"' /></td>";
         }
         else m+= "<TD></td>"
         m += "<TD><img width='20px' height='20px' src='https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+item.id+".jpg' /> "+item.name.substr(0,25)+"</td>";
           if(item.usable) {
         m += "<TD><input type=text size=2 id='pb_inv_court_"+item.id+"' /></td>";
         }
         else m+= "<TD>  </td>"
         m += "<TD>"+item.count+"</td>";
         m += (count%3 == 2)?"</tr>":"";
         count++;
      }
      m += "</table>";
      div.innerHTML = (count!=0)?m:"<CENTER>No useable items in this category</CENTER>";
      
      var nodes = document.getElementsByClassName("pbinv_"+t.type);
      if(nodes.length > 0){
         for(var i=0; i<nodes.length; i++){
            nodes[i].addEventListener('click', function(e){
               var item = JSON.parse(e.target.getAttribute("data-ft"));
               if(e.target.checked)
                  $("pb_inv_"+t.type+"_"+item.id).value = $("pbinventory_useall").checked?item.count:1;
               else
                  $("pb_inv_"+t.type+"_"+item.id).value = '';
            },false);
         }
      }
   },
   
   e_total : function (){
      var t = Tabs.Inventory;
      return t.max;
   },
   start : function (){
      var t = Tabs.Inventory;
      if(t.isBusy){
         t.isBusy = false;
         $("pbinventory_start").value = "Start";
      } else {
         t.isBusy = true;
         $("pbinventory_start").value = "Stop";
         t.queue = [];
         $("pbinventory_info").innerHTML = "";
         var nodes = document.getElementsByClassName("pbinv_"+t.type);
         for(var i = 0; i < nodes.length; i++){
            if(nodes[i].checked){
               try{
                  t.queue.push(JSON.parse(nodes[i].getAttribute("data-ft")));
               } catch (e){
                  logit(inspect(e,7,1));
               }
            }
         }
         if(t.queue.length > 0)
            t.nextqueue();
      }
   },
   
   nextqueue : function (){
      var t = Tabs.Inventory;
      if(!t.isBusy)
         return;
      var div = $("pbinventory_info");
      var m = document.createElement('span');
      if(t.queue.length > 0){
         var item = t.queue[0];
         t.counter = 0;
         t.max = parseIntNan($("pb_inv_"+t.type+"_"+item.id).value);
         m.innerHTML = "<span id='pb_inv_info_"+item.id+"'>Using item "+item.name+" <span id='pb_inv_info_count_"+item.id+"'>1</span> of <span id='pb_inv_info_max_"+item.id+"'>"+t.max+"</span>. Left <span id='pb_inv_info_left_"+item.id+"'>"+(t.max-t.counter)+"</span> <span id='pb_inv_info_extra_"+item.id+"'> </span></span><br />";
      } else {
         m.innerHTML = "Completed! \n";
         t.isBusy = false;
         $("pbinventory_start").value = "Start";
      }
      if(div.firstChild){
         div.insertBefore(m, div.firstChild);
      } else {
         div.appendChild(m);
      }
      if(t.ItemController.isAvailable)
         t.useitem_new();
      else
         t.useitem();
   },
   
   useitem_new : function (){
      var t = Tabs.Inventory;
      if(!t.isBusy)
         return;
      t.ItemController.setEnable(true); //Set to use current value specified
      if(t.city.city.id){ //Set to use city specified
         t.city_holder = unsafeWindow.currentcityid;
         unsafeWindow.currentcityid = t.city.city.id;
      }
      var item = t.queue[0];
      $("pb_inv_info_left_"+item.id).innerHTML = 0;
      $("pb_inv_info_count_"+item.id).innerHTML = t.max;
      unsafeWindow.cm.ItemController.use(item.id);
      setTimeout(t.wait_new, 250, 0);
   },
   
   wait_new : function (){
      var t = Tabs.Inventory;
      if(!t.isBusy)
         return;
      var item = t.queue[0];
      item = unsafeWindow.ksoItems[item.id];
      t.queue[0] = item;
      $("pb_inv_info_extra_"+item.id).innerHTML = "All done";
      t.queue.shift();
      t.ItemController.setEnable(false); //Switch off value fixed
      if(t.city.city.id){ //Set currentcity to old value
         unsafeWindow.currentcityid = t.city_holder;
      }
      t.nextqueue();
   },
   
   useitem : function (){
      var t = Tabs.Inventory;
      if(!t.isBusy)
         return;
      var item = t.queue[0];
      unsafeWindow.cm.ItemController.use(item.id);
      setTimeout(t.wait, 250, 0);
   },
   
   wait : function (retries){
      var t = Tabs.Inventory;
      if(!t.isBusy)
         return;
      var item = t.queue[0];
      item = unsafeWindow.ksoItems[item.id];
      t.queue[0] = item;
      t.counter++;
      $("pb_inv_info_count_"+item.id).innerHTML = t.counter;
      $("pb_inv_info_left_"+item.id).innerHTML = (t.max-t.counter);
      if(t.counter >= t.max){
         $("pb_inv_info_extra_"+item.id).innerHTML = "All done";
         t.queue.shift();
         t.nextqueue();
         return;
      }
      $("pb_inv_info_extra_"+item.id).innerHTML = "Done. Wait for 1 second..";
      setTimeout(t.useitem, 150);
   },
   
   show: function (){
   
   },
   hide: function (){
   
   }
}
/************************  March Tab ************************/
Tabs.March = {
  tabOrder: 999998,
  tabLabel: 'March',
  myDiv: null,
  cityID: null,
  rallypointlevel:null,
  maxsend:0,
  dist:0,
  ETAstr:null,
  ETAType:null,
  checkETA:null,
  knt:null,
  ETAstr:null,
  ETAType:null,
  checkETA:null,
  resources:["food","wood","stone","iron","aetherstone"],
  speed:["0,0","0,180","0,200","0,3000","0,300","0,275","0,250","1,1000","1,750","1,150","1,100","1,120","1,80","0,900","0,500","1,775"],

    init: function(div){
    	var t = Tabs.March;
        t.myDiv = div;
        unsafeWindow.RemoveQueue = t.RemoveQueue;

        t.i931 = 0;
	    t.i932 = 0;
	    t.i55 = 0;
	    t.i57 = 0;
	    
	    if (Seed.items['i'+931]) t.i931 = Seed.items['i'+931];
	    if (Seed.items['i'+932]) t.i932 = Seed.items['i'+932];
	    if (Seed.items['i'+55]) t.i55 = Seed.items['i'+55];
	    if (Seed.items['i'+57]) t.i57 = Seed.items['i'+57];

      	var m = t.PaintContent();
      	t.myDiv.innerHTML = m;

      	if (t.i931 == 0) document.getElementById('AuraOfCommand').disabled = true; else document.getElementById('AuraOfCommand').disabled = false;
      	if (t.i932 == 0) document.getElementById('AuraOfConquest').disabled = true; else document.getElementById('AuraOfConquest').disabled = false;
      	if (t.i55 == 0) document.getElementById('GreenGriffin').disabled = true; else document.getElementById('GreenGriffin').disabled = false;
      	if (t.i57 == 0) document.getElementById('RedDragon').disabled = true; else document.getElementById('RedDragon').disabled = false;

      	t.from = new CdispCityPicker ('pbMfrom', document.getElementById('pbMcityFrom'), true, t.ClickCitySelect, 0);  
      	t.to = new CdispCityPicker ('pbMcityTo', document.getElementById ('pbMcityTo'), true, t.citySelNotify);
		t.to.bindToXYboxes(document.getElementById ('MtargetX'), document.getElementById ('MtargetY'));

      	for (i=1;i<=17;i++)  document.getElementById('M_Max'+i).addEventListener('click', function(){t.CalcMax(this.id);t.ETA();}, false);
        for (i=0;i<5;i++)  document.getElementById('M_R_Max'+i).addEventListener('click', function(){t.Calc_R_Max(this.id)}, false);
        for (i=1;i<=17;i++)  document.getElementById('M_Unt'+i).addEventListener('change', function(){t.ETA()}, false);	
        document.getElementById('MtargetX').addEventListener('change', function(){if (document.getElementById("MtargetX").value != "" && document.getElementById("MtargetY").value != "") document.getElementById('M_Dist'). innerHTML = "Dist.: " + distance(t.from.city.x, t.from.city.y, document.getElementById("MtargetX").value, document.getElementById("MtargetY").value);}, false);
    	document.getElementById('MtargetY').addEventListener('change', function(){if (document.getElementById("MtargetX").value != "" && document.getElementById("MtargetY").value != "") document.getElementById('M_Dist'). innerHTML = "Dist.: " + distance(t.from.city.x, t.from.city.y, document.getElementById("MtargetX").value, document.getElementById("MtargetY").value);}, false);
		document.getElementById('addToQueue').addEventListener ('click', t.GetCoords,false); 	
		document.getElementById('ManualMarch').addEventListener ('click', t.ManualMarch,false);
		document.getElementById('pbMarchType').addEventListener ('click', t.MarchType,false);
		document.getElementById('RedDragon').addEventListener ('click', t.PaintMarchSize,false);
		document.getElementById('AuraOfCommand').addEventListener ('click', t.PaintMarchSize,false);
		document.getElementById('AuraOfConquest').addEventListener ('click', t.PaintMarchSize,false);
		document.getElementById('GreenGriffin').addEventListener ('click', function(){if (document.getElementById('GreenGriffin').checked) document.getElementById('RedDragon').checked = false;t.ETA();},false);
		document.getElementById('RedDragon').addEventListener ('click', function(){if (document.getElementById('RedDragon').checked) document.getElementById('GreenGriffin').checked = false;t.ETA();},false);
        if (MarchOptions.Queue.length > 0) t.PaintQueue();
        t.PaintMarchSize(); 
        t.ClickCitySelect();  
        t.MarchType();
    },

    PaintContent : function (){
    	var t = Tabs.March;
    	var color = "black";
    	var m = '<DIV id=pbReinfMain class=pbStat>INFO</div><DIV id=MPresetCont></div>'; 
      	m += '<DIV id=pbReinfMain class=pbStat>MARCH (SAVE MARCHES TO LAUNCH MANUALLY)</div><TABLE id=pireinforce width=80% height=0% class=pbTab>';    
      	m += '<TR><TD><B>From City: </b></td><TD><SPAN id=pbMcityFrom></span></td></tr>';
      	m += '<TR><TD><B>To City:</b></td><TD><SPAN id=pbMcityTo></span></td><TD><INPUT id=MtargetX maxlength=3 type=text>&nbsp&nbsp&nbspY:&nbsp<INPUT id=MtargetY maxlength=3 type=text></td>';
      	m += '<TD><SPAN id=M_Dist>Dist.: N/A</span></td><TD><SPAN id=M_ETA>ETA.: N/A</span></td></tr></table>';
    	m += '<TABLE id=pbMarch width=100% height=0% class=pbTab><TR>';
      
 

for (i=1;i<=5;i++) m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD><SPAN id=M_unit'+i+'></span></td>';
      	m+='</tr><TR>';
        
      	for (i=1;i<=5;i++) m += '<TD><INPUT id=M_Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=M_Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';   	
      	for (i=6;i<=10;i++) m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD><SPAN id=M_unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=6;i<=10;i++) m += '<TD><INPUT id=M_Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=M_Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';
      	for (i=11;i<=15;i++) m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD><SPAN id=M_unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=11;i<=15;i++) m += '<TD><INPUT id=M_Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=M_Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';
        for (i=16;i<=17;i++) m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD><SPAN id=M_unit'+i+'></span></td>';
      	m+='</tr><TR>';
      	for (i=16;i<=17;i++) m += '<TD><INPUT id=M_Unt'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=M_Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';
      	m+='</tr><TR>';
      

      	for (i=0;i<5;i++) m += '<TD rowspan="2"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+t.resources[i]+'_30.png"></td><TD><SPAN id=M_recInfo'+i+'></span></td>';
      	m+='</tr><TR>';
        for (i=0;i<5;i++) m += '<TD><INPUT id=M_Recource'+i+' type=text size=10 maxlength=10 value="0"><INPUT id=M_R_Max'+i+' type=submit class=pbButton value='+translate("Max")+'></td>';

	    m += '</tr></table><BR><TABLE id=pbReinfETA width=90% height=0% align="center" class=pbTab>';
	    m += '<TR align="center"><TD rowspan=2 width=150px><SELECT id="pbMarchType"><OPTION value=5>Reassign</option><OPTION value=4>Attack</option><OPTION value=3>Scout</option><OPTION value=2>Reinforce</option></select></td>';
	    m += '<TD rowspan=2><SELECT id=M_Knight type=list></select></td>';
	    m += '<TD rowspan=2 width=100px><a class="button20" id=addToQueue><span>Save march</span></a></td><TD rowspan=2 width=100px><a class="button20" id=ManualMarch><span>Manual March</span></a></td>';
	    m += '<TD style="width:30px;text-align:right"><INPUT id=AuraOfCommand type=checkbox unchecked=true><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/30/931.jpg></td>';
	    m += '<TD style="width:30px;text-align:right"><INPUT id=AuraOfConquest type=checkbox unchecked=true><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/30/932.jpg></td>';
	    m += '<TD style="width:30px;text-align:right"><INPUT id=GreenGriffin type=checkbox unchecked=true><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/30/55.jpg></td>';
	    m += '<TD style="width:30px;text-align:right"><INPUT id=RedDragon type=checkbox unchecked=true><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/30/57.jpg></td>';

	    if (t.i931 == 0) color = "red"; else color = "black";
	    m+= '<TR align="center"><TD align=right><FONT color='+color+'>'+t.i931+'</font></td>';
	    if (t.i932 == 0) color = "red"; else color = "black";
	    m+= '<TD align=right><FONT color='+color+'>'+t.i932+'</font></td>'
	    if (t.i55 == 0) color = "red"; else color = "black";
	    m+= '<TD align=right><FONT color='+color+'>'+t.i55+'</font></td>'
	    if (t.i57 == 0) color = "red"; else color = "black";
	    m+= '<TD align=right><FONT color='+color+'>'+t.i57+'</font></td>'
	    m += '</tr></table>';
	    m+= '<BR><DIV id=MarchInfo></div>';
	    m+= '<BR><DIV id=pbReinfMain class=pbStat>Saved Marches</div><BR><BR><DIV id=M_Queue></div>';
	    return m;
    },

    ListKnights : function(){
       	var t = Tabs.March;
       	var knt = new Array();
       	for (k in Seed.knights['city' + t.from.city.id]){
       		if (Seed.knights['city' + t.from.city.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.from.city.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["politicsKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["combatKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["intelligenceKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"]){
       			knt.push ({
       				Name:   Seed.knights['city' + t.from.city.id][k]["knightName"],
       				Combat:	(parseInt(Seed.knights['city' + t.from.city.id][k]["combat"])+((Seed.knights['city' + t.from.city.id][k]["combatBoostExpireUnixtime"]>0)?(Math.floor(parseInt(Seed.knights['city' + t.from.city.id][k]["combat"])*0.25)):0)),
       				ID:		Seed.knights['city' + t.from.city.id][k]["knightId"],
       			});
       		}
       	}
       	knt = knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
      	document.getElementById('M_Knight').options.length=0;	
		if (document.getElementById('pbMarchType').value != 4) t.AddZeroKnight();
       	for (k in knt){
    			if (knt[k]["Name"] !=undefined){
	    			var o = document.createElement("option");
	    			o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +')')
	    			o.value = knt[k]["ID"];
	    			document.getElementById("M_Knight").options.add(o);
    			}
    	}
    	if (document.getElementById('pbMarchType').value == 4) t.AddZeroKnight();
    },

    AddZeroKnight: function(){
    	var o = document.createElement("option");
		o.text = '--Choose a Knight--';
		o.value = 0;
		document.getElementById("M_Knight").options.add(o);
    },

    PaintMarchSize : function (){
    	var t = Tabs.March;
    	var Aura = 0;
    	if (document.getElementById('AuraOfCommand').checked) Aura = 25;
    	if (document.getElementById('AuraOfConquest').checked) Aura = 50;
   		t.getRallypoint("city" + t.from.city.id);
    	RallypointMax = (t.rallypointlevel * 10000);
    	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
    	//t.maxsend = RallypointMax + ((RallypointMax / 100) * TR);
    	t.maxsend = RallypointMax + Math.round(RallypointMax * (TR / 100));
		var prestigeRallyPercent = 1.40;
    	if (Seed.cityData.city[t.from.city.id].isPrestigeCity) {
			for (var i=1;i<=6;i++){
				i <= 2 ? prestigeRallyPercent += 0.10 : prestigeRallyPercent += 0.05;
				if (i == (parseInt(Seed.cityData.city[t.from.city.id].prestigeInfo.prestigeLevel))) { t.maxsend = Math.floor(t.maxsend * prestigeRallyPercent);	break;}			
			}
    		for (var bl=0;bl<Seed.cityData.city[t.from.city.id].prestigeInfo.blessings.length;bl++) if (Seed.cityData.city[t.from.city.id].prestigeInfo.blessings[bl]==207) t.maxsend = Math.round(t.maxsend * 1.10);
    	}
    	t.maxsend = t.maxsend * (1 + (Aura/100));  	
    	var m = 'March Size: ' + addCommas(Math.floor(t.maxsend)) + ' (TR: ' + TR + '% - Aura: ' + Aura + '%)';
    	document.getElementById('MPresetCont').innerHTML = m;
    },

    MarchType : function(){
    	var t = Tabs.March;  
    	if (document.getElementById('pbMarchType').value == 3) {
    		for (var i=1;i<=17;i++) if (i!=3) {
    			document.getElementById('M_Unt'+i).disabled = true;
    			document.getElementById('M_Unt'+i).value = 0;
    			document.getElementById('M_Max'+i).disabled = true;
    		} else if (Seed.units["city" + t.from.city.id]["unt"+i] ==0) {
    			document.getElementById('M_Unt'+i).disabled = true;
    			document.getElementById('M_Unt'+i).value = 0;
    			document.getElementById('M_Max'+i).disabled = true;
    		} else {
    			document.getElementById('M_Unt'+i).disabled = false;
	    		document.getElementById('M_Max'+i).disabled = false; 
    		}
    	} else for (var i=1;i<=17;i++) {
    		if (Seed.units["city" + t.from.city.id]["unt"+i] == 0) {
	    		document.getElementById('M_Unt'+i).disabled = true;
	    		document.getElementById('M_Unt'+i).value = 0;
	    		document.getElementById('M_Max'+i).disabled = true; 
	    	} else {
	    		document.getElementById('M_Unt'+i).disabled = false;
	    		document.getElementById('M_Max'+i).disabled = false; 
	    	}
    	}

    	if (document.getElementById('pbMarchType').value != 2&& document.getElementById('pbMarchType').value != 5) for (i=0;i<5;i++) {document.getElementById('M_Recource'+i).disabled = true;document.getElementById('M_R_Max'+i).disabled = true;document.getElementById('M_Recource'+i).value = 0;}
    	else for (i=0;i<5;i++) {document.getElementById('M_Recource'+i).disabled = false;document.getElementById('M_R_Max'+i).disabled = false;}
    	t.ListKnights();
    },

    ShowWarning: function(msg,ok){
    	var t = Tabs.March;
    	if (ok) var color = "green";
    	 else var color = "red";
    	document.getElementById('MarchInfo').innerHTML = '<FONT color='+color+'><B>' + msg + '</b></font>';
    },

    ManualMarch : function (){
    	var t = Tabs.March;
    	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	var total = 0;
		params.kid = document.getElementById("M_Knight").value;
		if (params.kid == 0 && document.getElementById('pbMarchType').value==4) {t.ShowWarning('Please select a knight...',false);return;}
		params.cid=t.from.city.id;
    	params.type=document.getElementById('pbMarchType').value;
	    params.xcoord = document.getElementById('MtargetX').value;
	    params.ycoord = document.getElementById('MtargetY').value;
	    TroopsOK = true;
	    for (var i=1;i<=17;i++){
	    	TroopsInCity = Seed.units['city'+t.from.city.id]['unt'+i];
    		if (parseInt(TroopsInCity) < parseInt(document.getElementById('M_Unt'+i).value)) TroopsOK = false;
    		else if (parseInt(document.getElementById('M_Unt'+i).value) > 0) params['u'+i]=parseInt(document.getElementById('M_Unt'+i).value);
	    }
	    for (i=0;i<5;i++) params['r'+(i+1)] = document.getElementById('M_Recource'+i).value; 
	    if (!TroopsOK) return;

	    if (params.xcoord =="" || params.xcoord=="") {t.ShowWarning("Please enter coords...",false);return;}
	    for (i=1;i<=17;i++) total += parseInt(document.getElementById('M_Unt'+i).value);
	    if (total == 0) {t.ShowWarning("You got to send a least one troop...",false);return;}
		if (total > t.maxsend) {t.ShowWarning("Can't send out that amount of troops, wrong TR cards or Aura?",false);return;}

	    var items=new Array();
	    if (document.getElementById('AuraOfCommand').checked) items.push(931);
	    if (document.getElementById('AuraOfConquest').checked) items.push(932);
	    if (document.getElementById('GreenGriffin').checked) items.push(55);
	    if (document.getElementById('RedDragon').checked) items.push(57);
	    if (items.length > 0) params.items=items.join(","); 
	     
    	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
              method: "post",
              parameters: params,
              loading: true,
              onSuccess: function (transport) {
                  var rslt = eval("(" + transport.responseText + ")");
                  if (rslt.ok) {
	                  var now = unixTime();
	                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                  var ut = unixTime();
	                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	                  for(i = 0; i <= unitsarr.length; i++) if(params["u"+i]) unitsarr[i] = params["u"+i];  
	                  var resources=new Array();
	                  resources[0] = params.gold;
	                  for(i=1; i<=4; i++) resources[i] = params["r"+i];
	                  var currentcityid = params.cid;
	                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                  if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};  
	                  for(var i=0;i<items.length;i++){
							Seed.items["i"+items[i]]=parseInt(Seed.items["i"+items[i]])-1;
							unsafeWindow.ksoItems[items[i]].subtract();
					  }
	                  //t.myDiv.innerHTML = "";
	                  //t.init(t.myDiv);
	                  switch (parseInt(params.type)) {
							case 1: var type = "TRANSPORT";break;
							case 2: var type = "REINFORCE";break;
							case 3: var type = "SCOUT";break;
							case 4: var type = "ATTACK";break;
							case 5: var type = "REASSIGN";break;
					  }
	                  msg = 'Send ' + type + ' to ' + coordLink(params.xcoord,params.ycoord);
	                  t.ShowWarning(msg,true);
	                  setTimeout(t.ShowWarning,5000,"",true)
	                  t.PaintMarchSize(); 
        			  t.ClickCitySelect();  
        			  t.MarchType();
                  } else {t.ShowWarning("Error: "+ rslt.msg,false)}
              },
              onFailure: function () {}
      });     

    },

    Calc_R_Max : function(what){
    	var t = Tabs.March;
    	var otherResources = 0;
    	var maxload = 0;
    	var otherRes = 0;
    	id = what.substr(7);
		for (i=1;i<=17;i++) if (parseInt(document.getElementById('M_Unt'+i).value) > 0) maxload += getMaxLoad(i,parseInt(document.getElementById('M_Unt'+i).value));
		for (i=0;i<5;i++) if (id != i) otherRes += parseInt(document.getElementById('M_Recource' + i).value);
		maxload = maxload - otherRes;
		document.getElementById('M_Recource'+id).value = maxload;
    },

    CalcMax : function (i){
    	var t = Tabs.March;
    	var othertroops=0;
    	var max=0;
    	id = i.substr(5);
    	var rallypointlevel = 0;
    	for (var o in Seed.buildings["city"+ t.from.city.id]){
		    var buildingType = parseInt(Seed.buildings["city"+ t.from.city.id][o][0]);
		    var buildingLevel = parseInt(Seed.buildings["city"+ t.from.city.id][o][1]);
		    if (buildingType == 12) rallypointlevel=parseInt(buildingLevel);
		}
    	if(rallypointlevel == 11) rallypointlevel = 15;
		if(rallypointlevel == 12) rallypointlevel = 20;
    	t.maxsend = (rallypointlevel * 10000);
		var prestigeRallyPercent = 1.40;
		if (Seed.cityData.city[t.from.city.id].isPrestigeCity) {
    		for (var i=1;i<=6;i++){
				i <= 2 ? prestigeRallyPercent += 0.10 : prestigeRallyPercent += 0.05;
				if (i == (parseInt(Seed.cityData.city[t.from.city.id].prestigeInfo.prestigeLevel))) { t.maxsend = Math.floor(t.maxsend * prestigeRallyPercent);break;}				
				}
    		for (var bl=0;bl<Seed.cityData.city[t.from.city.id].prestigeInfo.blessings.length;bl++) if (Seed.cityData.city[t.from.city.id].prestigeInfo.blessings[bl]==207) t.maxsend = Math.round(t.maxsend * 1.10);
    	}
    	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
    	//t.maxsend = t.maxsend + ((t.maxsend / 100) * TR);
    	t.maxsend += Math.round(t.maxsend * (TR / 100));
    	if (document.getElementById('AuraOfCommand').checked) t.maxsend = t.maxsend * 1.25;
    	if (document.getElementById('AuraOfConquest').checked) t.maxsend = t.maxsend * 1.50;
    	for (i=1;i<=15;i++) if (id !=i) othertroops += parseInt(document.getElementById('M_Unt'+i).value);
    	if (othertroops < t.maxsend) max = (t.maxsend - othertroops);   	
    	if (max > Seed.units["city" + t.from.city.id]["unt"+id]) max = Seed.units["city" + t.from.city.id]["unt"+id];
    	document.getElementById('M_Unt'+id).value = Math.floor(max);
    },

    ETA : function (){
    	var t = Tabs.March;
    	var a = {};
    	for (i=1;i<=17;i++) a[i] = document.getElementById('M_Unt'+i).value;
    	var items = {};

    	if (document.getElementById('GreenGriffin').checked) items["55"] = true;
	     else if (document.getElementById('RedDragon').checked) items["57"] = true;
    	var dist = distance(t.from.city.x, t.from.city.y, document.getElementById("MtargetX").value, document.getElementById("MtargetY").value)
    	var ETA = marchTimeCalculator(a, false, items, t.from.city.id, document.getElementById('pbMarchType').value,dist);
    	document.getElementById('M_ETA').innerHTML = "ETA: " + ETA;
    },

	GetCoords : function (){
	    var t= Tabs.March;
	    var targetName = "";
	    var targetCityName = "";
	    var total=0;
	    targetX = document.getElementById('MtargetX').value;
	    targetY = document.getElementById('MtargetY').value;
	    if (targetX =="" || targetY=="") {alert("Please enter coords...");return;}
	    for (i=1;i<=17;i++) total += parseInt(document.getElementById('M_Unt'+i).value);
	    if (total == 0) {alert("You got to send a least one troop...");return;}
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.blocks = "bl_" + targetX + "_bt_" + targetY;
	    
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			if (rslt.data["l_"+targetX+"_t_"+targetY].tileType == 51) {
        				userId = rslt.data["l_"+targetX+"_t_"+targetY].tileUserId;
        				if (userId != null) targetName = rslt.userInfo["u" + userId]["n"];
        				targetCityName = rslt.data["l_"+targetX+"_t_"+targetY].cityName;
        			}
        			MarchOptions.Queue.push ({
        				what: 			"March",
        				city: 			t.from.city.id,
        				action: 		document.getElementById('pbMarchType').value,
        				targetX: 		targetX,
        				targetY: 		targetY,
        				tileType: 		rslt.data["l_"+targetX+"_t_"+targetY].tileType,
        				tileLevel: 		rslt.data["l_"+targetX+"_t_"+targetY].tileLevel,
        				targetCityName: targetCityName,
        				targetName: 	targetName,
        				cityNumber: 	rslt.data["l_"+targetX+"_t_"+targetY].cityNum,
        				1: 				document.getElementById('M_Unt1').value,
        				2: 				document.getElementById('M_Unt2').value,
        				3: 				document.getElementById('M_Unt3').value,
        				4: 				document.getElementById('M_Unt4').value,
        				5: 				document.getElementById('M_Unt5').value,
        				6: 				document.getElementById('M_Unt6').value,
        				7: 				document.getElementById('M_Unt7').value,
        				8: 				document.getElementById('M_Unt8').value,
        				9: 				document.getElementById('M_Unt9').value,
        				10: 			document.getElementById('M_Unt10').value,
        				11: 			document.getElementById('M_Unt11').value,
        				12: 			document.getElementById('M_Unt12').value,
        				13: 			document.getElementById('M_Unt13').value,
        				14: 			document.getElementById('M_Unt14').value,
        				15: 			document.getElementById('M_Unt15').value,
                16: 			document.getElementById('M_Unt16').value,	
                17: 			document.getElementById('M_Unt17').value,
        				r1: 			document.getElementById('M_Recource0').value,
        				r2: 			document.getElementById('M_Recource1').value,
        				r3: 			document.getElementById('M_Recource2').value,
        				r4: 			document.getElementById('M_Recource3').value,
        				r5: 			document.getElementById('M_Recource4').value
        			});
					t.PaintQueue();
					saveMarchOptions();
					for(i=1;i<=17;i++) document.getElementById('M_Unt'+i).value=0;
					document.getElementById('MtargetX').value="";
					document.getElementById('MtargetY').value="";
					Dashboard.ShowMarches();
        		}
      		},
    	});	
	},

PaintQueue : function (){
    var t= Tabs.March;
    document.getElementById('M_Queue').innerHTML = '<TABLE id=ShowQ class=pbStat align="center" width=80%></table>';
    for (k=(MarchOptions.Queue.length-1);k>=0;k--) t._addTab(MarchOptions.Queue[k],k);  
    t._addTabHeader();
 },

 _addTab: function(action,k){
    var t = Tabs.March;
    for (postcity in Seed.cities) if (Seed.cities[postcity][0] == action.city) logcity = Seed.cities[postcity][1];
    var total = 0;
	var info = "";
	var type="";
	for (i=1;i<=17;i++) total += parseInt(action[i]);
	switch (parseInt(action.tileType)) {
		case 0: info = "Bog";break;
		case 10: info = "Grassland";break;
		case 11: info = "Lake";break;
		case 20: info = "Woods";break;
		case 30: info = "Hills";break;
		case 40: info = "Mountain";break;
		case 50: info = "Plain";break;
		case 51: 
			if (action.targetCityName == null && !action.misted) info = "Barb Camp";
				else info = action.targetName;
			break;
		case 53: info = "Misted City";break;
	}
	switch (parseInt(action.action)) {
		case 1: type = "TRANSPORT";break;
		case 2: type = "REINFORCE";break;
		case 3: type = "SCOUT";break;
		case 4: type = "ATTACK";break;
		case 5: type = "REASSIGN";break;
	}
    var row = document.getElementById('ShowQ').insertRow(0);
    row.vAlign = 'top';
    row.style.color = "black";
    row.insertCell(0).innerHTML ='<A onclick="RemoveQueue('+ k +')"><img src=""/>';	  
    row.insertCell(1).innerHTML = logcity;
    row.insertCell(2).innerHTML = coordLink(parseInt(action.targetX),parseInt(action.targetY));
    row.insertCell(3).innerHTML = info;
    row.insertCell(4).innerHTML = action.targetCityName;
    row.insertCell(5).innerHTML = action.tileLevel;
    row.insertCell(6).innerHTML = addCommas(total);
    row.insertCell(7).innerHTML = '<a class="button20" id="Details' + k + '"><span>Details</span></a>&nbsp&nbsp&nbsp<a class="button20 ptButtonRed" id="doAction' + k + '"><span>'+ type+'</span></a>';
    document.getElementById('doAction' + k).addEventListener('click', function(){t.doMarch(action);}, false);
    document.getElementById('Details' + k).addEventListener('click', function(){t.DetailsPop(action,logcity,info);}, false);
},

_addTabHeader: function() {
    var t = Tabs.March;
    var row = document.getElementById('ShowQ').insertRow(0);
    row.vAlign = 'top';
    row.style.color = "black";
    row.insertCell(0).innerHTML = "&nbsp";
    row.insertCell(1).innerHTML = "From City";
    row.insertCell(2).innerHTML = "Coords";
    row.insertCell(3).innerHTML = "Target Name";
    row.insertCell(4).innerHTML = "City";
    row.insertCell(5).innerHTML = "Level";
    row.insertCell(6).innerHTML = "Troops";
    row.insertCell(7).innerHTML = "Action";
},

DetailsPop : function (action,logcity,info){
	var t = Tabs.March;
	var m = '<TABLE id=pbMarch width=100% height=0% class=pbTab>';
    m+= '<TR><TD width="50px"></td><TD>From city: ' + logcity + '</td></tr>';
    m+= '<TR><TD width="50px"></td><TD>Target: ' + info + '</td></tr>';
    m+= '<TR><TD width="50px"></td><TD>City: ' + action.targetCityName + '</td></tr>';
    m+= '<TR><TD width="50px"></td><TD>Level: ' + action.tileLevel + '</td></tr>';
    m+= '<TR><TD width="50px"></td><TD>Coords: ' +  coordLink(parseInt(action.targetX),parseInt(action.targetY)) + '</td></tr></table><BR>';
    m += '<TABLE id=pbMarch width=100% height=0% class=pbTab><TR>';
    for (i=1;i<=4;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
    m+='</tr><TR>'; 
    for (i=5;i<=8;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
    m+='</tr><TR>'; 
    for (i=9;i<=12;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
    m+='</tr><TR>';
    for (i=13;i<=16;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
    for (i=17;i<=17;i++) m += '<TD width="51px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"></td><TD width="75px">'+ addCommas(action[i]) +'</td>';
    
    m+='</tr></table><BR>'; 
	m += '<TABLE id=pbMarch width=100% height=0% class=pbTab><TR>';
    m+='<TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png"></td><TD width="100px">' + addCommas(action.r1) +'</td>';
	m+='<TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png"></td><TD width="100px">' + addCommas(action.r2) +'</td>';
	m+='<TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png"></td><TD width="100px">' + addCommas(action.r3) +'</td>';
	m+='<TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png"></td><TD width="100px">' + addCommas(action.r4) +'</td>';
	m+='</tr></TR><TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png"></td><TD width="100px">' + addCommas(action.r5) +'</td>';
	m+='<TD width="30px"><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png"></td><TD width="100px">' + addCommas(action.gold) +'</td>';
	m+='</tr></table>'; 	
    var pop = new pbPopup ('giftHelp', 0, 0, 550, 410, true);
    pop.centerMe (mainPop.getMainDiv());  
    pop.getMainDiv().innerHTML = m;
    pop.getTopDiv().innerHTML = '<CENTER><B>Saved March info</center>';
    pop.show (true);
  },


    
ClickCitySelect: function(city){
    var t = Tabs.March;  
    for (i=1;i<=17;i++) {
    	document.getElementById('M_unit'+i).innerHTML = addCommas(Seed.units["city" + t.from.city.id]["unt"+i]);
    	if (Seed.units["city" + t.from.city.id]["unt"+i] ==0) {
    		document.getElementById('M_Unt'+i).disabled = true;
    		document.getElementById('M_Unt'+i).value = 0;
    		document.getElementById('M_Max'+i).disabled = true;
    	}
    }
    for (i=0;i<=4;i++) {
    	var rec = 0;
    	if (i==4) rec = parseInt(Seed.resources["city" + t.from.city.id]['rec'+(i+1)][0]);
    	else rec = parseInt(Seed.resources["city" + t.from.city.id]['rec'+(i+1)][0]/3600);
    	document.getElementById('M_recInfo'+i).innerHTML = addCommas(Math.round(rec));	
    }
    if (document.getElementById("MtargetX").value != "" && document.getElementById("MtargetY").value != "") {
    	document.getElementById('M_Dist'). innerHTML = "Dist.: " + distance(t.from.city.x, t.from.city.y, document.getElementById("MtargetX").value, document.getElementById("MtargetY").value);
    	t.ETA();
    }
    t.ListKnights();
    t.PaintMarchSize();
    t.MarchType();
},

RemoveQueue: function(id){
    var t = Tabs.March;
    MarchOptions.Queue.splice(id,1);
    t.PaintQueue();
	saveMarchOptions();
	Dashboard.ShowMarches();
},
             
getKnights : function(){
   var t = Tabs.March;
   t.knt = new Array();
   for (k in Seed.knights['city' + t.from.city.id]){
           if (Seed.knights['city' + t.from.city.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.from.city.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["politicsKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["combatKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"] && Seed.leaders['city' + t.from.city.id]["intelligenceKnightId"] != Seed.knights['city' + t.from.city.id][k]["knightId"]){
               t.knt.push ({
                   Name:   Seed.knights['city' + t.from.city.id][k]["knightName"],
                   Combat:    parseInt(Seed.knights['city' + t.from.city.id][k]["combat"]),
                   ID:        Seed.knights['city' + t.from.city.id][k]["knightId"],
               });
           }
   }
   t.knt = t.knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
},

    
    getRallypoint: function(cityId){
      var t = Tabs.March;
      for (var o in Seed.buildings[cityId]){
        var buildingType = parseInt(Seed.buildings[cityId][o][0]);
        var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
        if (buildingType == 12) t.rallypointlevel=parseInt(buildingLevel);
       }
     if(t.rallypointlevel == 11) t.rallypointlevel = 15;
     if(t.rallypointlevel == 12) t.rallypointlevel = 20;      
 	},

  
    doMarch: function(action){
        var t = Tabs.March;
        t.getKnights();
		if (t.knt.toSource() == "[]") return;
		var kid = t.knt[0].ID;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.cid=action.city;
        params.type=action.action;
        if (action.action == 4 || action.action == 5) params.kid=kid;
        else params.kid=0;
        params.xcoord = action.targetX;
        params.ycoord = action.targetY;
        params.u1=action["1"];
        params.u2=action["2"];
        params.u3=action["3"];
        params.u4=action["4"];
        params.u5=action["5"];
        params.u6=action["6"];
        params.u7=action["7"];
        params.u8=action["8"];
        params.u9=action["9"];
        params.u10=action["10"];
        params.u11=action["11"];
        params.u12=action["12"];
        params.u13=action["13"];
        params.u14=action["14"];
        params.u15=action["15"];
        params.u16=action["16"];
        params.u17=action["17"];
        if (action.gold) params.gold = action.gold;
      	if (action.r1) params.r1= action.r1;
      	if (action.r2) params.r2= action.r2;
      	if (action.r3) params.r3= action.r3;
      	if (action.r4) params.r4= action.r4;
      	if (action.r5) params.r5= action.r5;
        
        var total=0;
    	var max = 0;
    	t.getRallypoint("city" + action.city);
    	RallypointMax = (t.rallypointlevel * 10000);
    	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    	if (TR > 150) TR=150;
    	//t.maxsend = RallypointMax + ((RallypointMax / 100) * TR);
    	t.maxsend = RallypointMax + Math.round(RallypointMax * (TR / 100));
    	if (Seed.cityData.city[t.from.city.id].isPrestigeCity) {
    		switch(parseInt(Seed.cityData.city[t.from.city.id].prestigeInfo.prestigeLevel)){
    			case 1: t.maxsend = Math.round(t.maxsend * 1.50);break;
    			case 2: t.maxsend = Math.round(t.maxsend * 1.60);break;
    			case 3: t.maxsend = Math.round(t.maxsend * 1.65);break;
          case 4: t.maxsend = Math.round(t.maxsend * 1.70);break;
case 5: t.maxsend = Math.round(t.maxsend * 1.75);break;
case 6: t.maxsend = Math.round(t.maxsend * 1.80);break;
    		}
    	}
    	for (i=1;i<=17;i++) total += parseInt(params["u"+i]);
    	if (total > t.maxsend) {alert("Can't send out that amount of troops, wrong TR cards?");return;}
    	
          new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
                  method: "post",
                  parameters: params,
                  loading: true,
                  onSuccess: function (transport) {
	                  var rslt = eval("(" + transport.responseText + ")");
	                  if (rslt.ok) {
		                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
		                  var ut = unixTime();
		                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		                  for(i = 0; i <= unitsarr.length; i++){
		                      if(params["u"+i]){
		                      unitsarr[i] = params["u"+i];
		                      }
		                  }
		                  var resources=new Array();
		                  resources[0] = params.gold;
		                  for(i=1; i<=4; i++){
		                      resources[i] = params["r"+i];
		                  }
		                  var currentcityid = params.cid;
		                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
		                  if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
	                  } 
           
                  },
                  onFailure: function () {}
          });
               
    },
    
    
    show: function(){
        var t = Tabs.March;
        if (MarchOptions.Queue.length > 0) t.PaintQueue();
    },
    hide: function(){
        var t = Tabs.March;
    },
    onUnload: function(){
    },
}

/************************  Gift Tab ************************/
Tabs.Gift = {
  tabLabel: 'Gift',
  myDiv: null,
  amount:0,
  Gifts:{},

    init: function(div){
    	var t = Tabs.Gift;
        t.myDiv = div;
      	var msg = '<DIV id=pbReinfMain class=pbStat>GIFT TAB</div>';
      	msg += '<BR>Select the gift you want to receive (only works when people are running AIO!), your avatar will be used to determine the gift, so don\'t change it!!';
      	msg += '<BR>It will spread out gifting, so if your alliance has 100 members, everybody should get a gift every 4 days from the same member.';
      	msg += '<BR>FYI, it will send out gifts to people not running AIO...';
      	msg += '<BR><BR><INPUT type=checkbox id=GiftOption '+((Options.sendGift)?'checked':'unchecked')+'>&nbspAutomatically send gifts.'
      	msg+='<BR><DIV id=GiftInfo></div>';
      	t.myDiv.innerHTML = msg;
      	document.getElementById('GiftOption').addEventListener('click', function(){Options.sendGift=this.checked;saveOptions();}, false);
       	t.GetGifts();    
    },

    GetGifts: function(){
    	var t = Tabs.Gift;
    	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.ctrl = 'GiftItems';
    	params.action = 'getGiftItems';
    	 
    	new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
        	method: "post",
          	parameters: params,
          	onSuccess: function (rslt) {
            	if (rslt) {
            		var m ='';
            		for (var i=0;i<rslt.giftItems.length;i++) {
            			t.Gifts[i+1] = rslt.giftItems[i].itemId;
            			m += '<BR><input id="Gift_'+rslt.giftItems[i].itemId+'"" type="radio" name="GiftTypes" value="Cities">' + rslt.giftItems[i].name + ': ' + rslt.giftItems[i].description;
            		}
            		document.getElementById('GiftInfo').innerHTML = m;
            		for (var i=0;i<rslt.giftItems.length;i++)  document.getElementById('Gift_'+ rslt.giftItems[i].itemId).addEventListener('click', function(){t.changeAvatar(this.id);}, false);

            		if (unsafeWindow.seed.player.avatarId > 10) {
            			document.getElementById('Gift_' + t.Gifts[1]).checked = true;
            			t.changeAvatar('Gift_' + t.Gifts[1]);
            		} else document.getElementById('Gift_' + t.Gifts[unsafeWindow.seed.player.avatarId]).checked = true;

            	}
          	},
        });
    },

    changeAvatar: function(id){
    	var t = Tabs.Gift;
    	var avatar = 16;
    	id = id.substr(5);
    	for (i in t.Gifts) 	if (t.Gifts[i] == id) avatar = i;
    	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.aid = avatar;
    	 
    	new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/changeAvatar.php" + unsafeWindow.g_ajaxsuffix, {
        	method: "post",
          	parameters: params,
          	onSuccess: function (rslt) {
            	if (rslt.ok) {
            		unsafeWindow.seed.player.avatarId = params.aid;
           			var d = unsafeWindow.seed.player.avatarurl.lastIndexOf("/");
                    var c = unsafeWindow.seed.player.avatarurl.substr(d + 2);
                    var e = params.aid + ".png";
                    unsafeWindow.seed.player.avatarurl = unsafeWindow.seed.player.avatarurl.replace(c, e);
                    //var f;
                    //((unsafeWindow.seed.player.prefix == "Lord") ? f = "m" : f = "f");
                   	//unsafeWindow.jQuery("#hudAvatarPic").attr("class", "avatars_50 " + f + unsafeWindow.seed.player.avatarId);
            	}
          	},
        });
    },

    Check: function(){
    	var t = Tabs.Gift;
    	var now = unixTime();
    	if (!Options.sendGift) return;
    	if ((Options.lastGiftSend + (6*60*60)) > now) return;
    	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'allianceGifting\\AllianceGiftingServiceAjax';
		params.action = 'getRecipients';
		
	  	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			loading: true,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok) {
					t.amount = parseInt(rslt.freeSlot);
					if (t.amount > 0) t.MakeGiftList(rslt.recipients);
				}
			},
			onFailure: function () {},
		});
    },

    MakeGiftList: function(recipients){
    	var t = Tabs.Gift;
    	var helpArray = {};
    	var GiftList = new Array();
    	var AvatarList = {1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]};
    	for (var i=0;i<recipients.length;i++) if (recipients[i].userId == 9666766 || recipients[i].userId == 9688786) helpArray[recipients[i].userId] = {avatar:recipients[i].avatarId,lastSend:0};
    	for (var i=0;i<recipients.length;i++) {
    		if (Options.GiftSendTo[recipients[i].userId] == undefined) Options.GiftSendTo[recipients[i].userId] = 1;
    		helpArray[recipients[i].userId] = {avatar:recipients[i].avatarId,lastSend:Options.GiftSendTo[recipients[i].userId]};
    	}
    	saveOptions();
    	for (var i in helpArray) GiftList.push({id:i,avatar:helpArray[i].avatar,lastSend:helpArray[i].lastSend});
    	GiftList = GiftList.sort(function sort(a,b) {a = a['lastSend'];b = b['lastSend'];return a == b ? 0 : (a < b ? -1 : 1);});
    	for (var i=0;i<t.amount;i++) {
    		var avatar = 1;
    		if (GiftList[i]) {
    			if (parseInt(GiftList[i].avatar) <= 10) avatar = parseInt(GiftList[i].avatar);
    			AvatarList[avatar].push(parseInt(GiftList[i].id));
    		}
    	}
		for (i=1;i<=10;i++) if (AvatarList[i].length > 0) setTimeout(t.SendGift,(i*5000),AvatarList[i],i);
    },

    SendGift: function(recipients,i){
    	var t = Tabs.Gift;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = 'allianceGifting\\AllianceGiftingServiceAjax';
		params.action = 'sendGift';
		params.recipients = String(recipients).replace(/,/g,"|");
		params.itemId = t.Gifts[i];
		 
		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				loading: true,
				onSuccess: function (transport) {
					var rslt = eval("(" + transport.responseText + ")");
					if (rslt.ok){
						var now = unixTime();
						Options.lastGiftSend = now;
						for (y in rslt.succeedRecipients) {
							Options.GiftSendTo[recipients[y].userId] = now;
							saveOptions();
						}
						actionLog('Send: ' + rslt.succeedRecipients.length + 'x ' + unsafeWindow.itemlist['i'+params.itemId].name);
					}
				},
				onFailure: function () {},
		});
	},

    show: function(){},
    hide: function(){},
}


/************************  AutoTrain Tab ************************/
Tabs.AutoTrain = {
  tabOrder: 120,
  tabLabel: unsafeWindow.g_js_strings.commonstr.train,
  myDiv: null,
  city:0,
  gamble : {"1":{"min":"5","max":"15","cost":"2"},"2":{"min":"10","max":"25","cost":"4"}},
  
  init: function(div){
    var t = Tabs.AutoTrain;
    t.myDiv = div;
    t.city = 0;
    t.nextcity();
    he = 999;
    
    var m = '<DIV class=pbStat>AUTO TRAIN</div><TABLE width=100% height=0% class=pbTab><TR><TD width=200></td>';
      
        
        m += '<TD align=center><INPUT id=pbAutoTrainState type=submit value="'+translate("AutoTrain")+' = '+ (TrainOptions.Running?'ON':'OFF')+'"></td>';
        m += '<TD align=right><INPUT id=pbShowTrainHelp type=submit value='+translate("HELP")+'></td></tr></table>';
        m += '<table width = 100% ><tr><td align=left><INPUT id=pbatTR type=checkbox '+(TrainOptions.tr?'CHECKED':'')+'> '+translate('Only train when throne room set')+' <INPUT id=pbatTRset type=text size=2 maxlength=2 value="'+ TrainOptions.trset +'">  '+translate('is equiped') +'<td align=left>'+translate('dismissing &nbsp'+unsafeWindow.unitcost['unt'+TrainOptions.DisUnt][0]);
      
      m+='<table><TD colspan=2><SELECT id=pbatDisUnt>';  // mac mod
       m+='  <option value ="0">---SELECT---</option>';
       m+='  <option value ="1">'+unsafeWindow.unitcost['unt1'][0]+'</option>';
       m+='  <option value ="2">'+unsafeWindow.unitcost['unt2'][0]+'</option>';
       m+='  <option value ="3">'+unsafeWindow.unitcost['unt3'][0]+'</option>';
       m+='  <option value ="4">'+unsafeWindow.unitcost['unt4'][0]+'</option>';
       m+='  <option value ="5">'+unsafeWindow.unitcost['unt5'][0]+'</option>';
       m+='  <option value ="6">'+unsafeWindow.unitcost['unt6'][0]+'</option>';
       m+='  <option value ="7">'+unsafeWindow.unitcost['unt7'][0]+'</option>';
       m+='  <option value ="8">'+unsafeWindow.unitcost['unt8'][0]+'</option>';
       m+='  <option value ="9">'+unsafeWindow.unitcost['unt9'][0]+'</option>';
       m+='  <option value ="10">'+unsafeWindow.unitcost['unt10'][0]+'</option>';
       m+='  <option value ="11">'+unsafeWindow.unitcost['unt11'][0]+'</option>';
       m+='  <option value ="12">'+unsafeWindow.unitcost['unt12'][0]+'</option>';
       m+= '</select>&nbsp  refresh required use at YOUR OWN RISK!!!' ;
   
           
     
         
    
        m += '</table></tr></table></div>';
        m += '<DIV class=pbStat>TRAIN OPTIONS</div><TABLE width=100% height=0% class=pbTab><TR align="center">';
    for (i=0;i<Seed.cities.length;i++){
      var citynum = Seed.cities[i][0];
        city = i+1;
          m += '<TABLE width=100% height=0% class=pbTab><TR align="left">';
          m+='<TR><TD width=30px><INPUT type=checkbox class='+city+' id="SelectCity'+city+'">';    // mac mod
        m+='<TD><TABLE><TR>';
        m+='<TD><B>'+ Seed.cities[i][1] +'</b></td>';
        m+='<TD width=150px><SELECT class='+city+' id="TroopsCity'+city+'"><option value="Select">--Select--</options>';
            for (y in unsafeWindow.unitcost) {
                var faux = 0;
                var uc = unsafeWindow.unitcost[y];
            if (matTypeof(uc[8]) == 'object'){
               if(!Seed.cityData.city[citynum].isPrestigeCity) {
                  for (k in uc[8]){
                     var b = getCityBuilding (Seed.cities[i][0], k.substr(1));
                     if (b.maxLevel < uc[8][k][1]){
                        faux = 1;
                        break;
                     }
                  }
               }else {
                  if(uc[8]['b13']) {
                     var b = getCityBuilding (Seed.cities[i][0], 13);
                     if (b.maxLevel < uc[8]['b13'][1]){
                        faux = 1;
                     }
                  }
               }  
            }
                if (matTypeof(uc[9]) == 'object'){
                    for (k in uc[9]){
                        if (parseInt(Seed.tech['tch'+k.substr(1)]) < uc[9][k][1]){
                            faux = 1;
                            break;
                        }
                    }
                }
                if(y == "unt13") faux = 1;
            if(y == "unt14") faux = 1;
            if(y == "unt15") faux = 1;
            
                if (faux==0)
                    m+='<option value="'+y.substr(3)+'">'+unsafeWindow.unitcost[y][0]+'</option>';
            }
        m+='</select></td>';
        m+='<TD width=100px>Min.: <INPUT class='+city+' id=treshold'+city+' type=text size=6 maxlength=6 value="'+ TrainOptions.Threshold[city]+'"\></td>';
        m+='<TD width=130px><INPUT type=checkbox class='+city+' id="SelectMax'+city+'"> '+translate("Max")+'.: <INPUT class='+city+' id=max'+city+' type=text size=6 maxlength=6 value="'+ TrainOptions.Max[city]+'"\></td>';
        m +='<TD>'+translate("Use Workers")+': ';
        m+='<SELECT class='+city+' id="workers'+city+'"><option value="0">0%</options>';
        m+='<option value="25">25%</options>';
        m+='<option value="50">50%</options>';
        m+='<option value="75">75%</options>';
        m+='<option value="100">100%</options></select>';
        m+='</td><td>';
        m += '<TD><SELECT class='+city+' id="TrainSpeedItem_'+city+'">\
        <option value=0><CENTER>--- '+unsafeWindow.g_js_strings.commonstr.items+' '+unsafeWindow.g_js_strings.commonstr.speedup+' ---</center></option>\
        <option value=36>'+unsafeWindow.itemlist.i36.name+'</option>\
        <option value=37>'+unsafeWindow.itemlist.i37.name+'</option>\
        <option value=38>'+unsafeWindow.itemlist.i38.name+'</option></select>';
        m+='dismiss active<INPUT type=checkbox class='+city+' id="DisTroops'+city+'"><BR>';  // mac mod
         m+='Auto use hourglass<INPUT type=checkbox class='+city+' id="autoHgUse'+city+'"></td></td></tr></table></td><tr>';  // mac mod
        m += '<TD></td><TD><TABLE><TR>';
        m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png"></td>';
        m += '<TD><INPUT class='+city+' id="KeepFood'+city+'" type=text size=7 maxlength=7 value="'+ TrainOptions.Keep[city]['Food']+'"\></td>';
        m += '<TD width=20px><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png"></td>';
        m += '<TD><INPUT class='+city+' id="KeepWood'+city+'" type=text size=7 maxlength=7 value="'+ TrainOptions.Keep[city]['Wood']+'"\></td>';
        m += '<TD width=20px><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png"></td>';
        m += '<TD><INPUT class='+city+' id="KeepStone'+city+'" type=text size=7 maxlength=7 value="'+ TrainOptions.Keep[city]['Stone']+'"\></td>';
        m += '<TD width=20px><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png"></td>';
        m += '<TD><INPUT class='+city+' id="KeepOre'+city+'" type=text size=7 maxlength=7 value="'+ TrainOptions.Keep[city]['Ore']+'"\></td>';
        m += '<TD><SELECT class='+city+' id="Resource'+city+'"><option value="true">'+translate("Keep")+'</options>';
        m+='<option value="false">'+translate("Use")+'</option>';
        m+='</select></td>';
          
        m += '<TD><SELECT class='+city+' id="TrainSpeed_'+city+'">\
        <option value=0><CENTER>--- '+unsafeWindow.g_js_strings.commonstr.speedup+' ---</center></option>\
        <option value=1>'+ t.gamble[1].cost+'x res ('+ t.gamble[1].min+' - '+t.gamble[1].max+'%)</option>\
        <option value=2>'+ t.gamble[2].cost+'x res ('+ t.gamble[2].min+' - '+t.gamble[2].max+'%)</option></select>';
        m+='</td></tr></table>';        
        if(Seed.cityData.city[citynum].prestigeInfo.blessings) {
        if(Seed.cityData.city[citynum].prestigeInfo.blessings.indexOf(11) != -1) {
         m += '<tr><td></td><td align=left><INPUT class='+city+' id=AsEnabled'+city+' type=checkbox '+(TrainOptions.AsEnabled[city]?'CHECKED':'')+'> Auto train '+unsafeWindow.unitcost['unt13'][0]+' '+translate("Min")+'.: <INPUT class='+city+' id=AsTroops'+city+' type=text size=6 maxlength=6 value="'+TrainOptions.AsTroops[city]+'"><INPUT type=checkbox class='+city+' id="AsSelectMax'+city+'"> '+translate("Max")+'.: <INPUT class='+city+' id=Asmax'+city+' type=text size=6 maxlength=6 value="'+ TrainOptions.AsMax[city]+'"\></td>';
      };
      if(Seed.cityData.city[citynum].prestigeInfo.blessings.indexOf(21) != -1) {
         m += '<tr><td></td><td align=left><INPUT class='+city+' id=AsEnabled'+city+' type=checkbox '+(TrainOptions.AsEnabled[city]?'CHECKED':'')+'> Auto train '+unsafeWindow.unitcost['unt14'][0]+' '+translate("Min")+'.: <INPUT class='+city+' id=AsTroops'+city+' type=text size=6 maxlength=6 value="'+TrainOptions.AsTroops[city]+'"><INPUT type=checkbox class='+city+' id="AsSelectMax'+city+'"> '+translate("Max")+'.: <INPUT class='+city+' id=Asmax'+city+' type=text size=6 maxlength=6 value="'+ TrainOptions.AsMax[city]+'"\></td>';
      };
      if(Seed.cityData.city[citynum].prestigeInfo.blessings.indexOf(31) != -1) {
         m += '<tr><td></td><td align=left><INPUT class='+city+' id=AsEnabled'+city+' type=checkbox '+(TrainOptions.AsEnabled[city]?'CHECKED':'')+'> Auto train '+unsafeWindow.unitcost['unt15'][0]+' '+translate("Min")+'.: <INPUT class='+city+' id=AsTroops'+city+' type=text size=6 maxlength=6 value="'+TrainOptions.AsTroops[city]+'"><INPUT type=checkbox class='+city+' id="AsSelectMax'+city+'"> '+translate("Max")+'.: <INPUT class='+city+' id=Asmax'+city+' type=text size=6 maxlength=6 value="'+ TrainOptions.AsMax[city]+'"\></td>';
      };
   }; 
        m+='</td></tr></table>';
    }
      
        t.myDiv.innerHTML = m;
      
    for (i=0;i<Seed.cities.length;i++){
        city = i+1;
        document.getElementById('TroopsCity'+city).value = TrainOptions.Troops[city];
        document.getElementById('SelectCity'+city).checked = TrainOptions.Enabled[city];
        document.getElementById('DisTroops'+city).checked = TrainOptions.KillTroops[city]; // mac mod
        document.getElementById('autoHgUse'+city).checked = TrainOptions.UseHourGlasses[city]; // mac mod a
         
        document.getElementById('Resource'+city).value = TrainOptions.Resource[city];
        document.getElementById('SelectMax'+city).checked = TrainOptions.SelectMax[city];
        document.getElementById('workers'+city).value = TrainOptions.Workers[city];
        document.getElementById('TrainSpeed_'+city).value = TrainOptions.Gamble[city];
        document.getElementById('TrainSpeedItem_'+city).value = TrainOptions.Item[city];
        if (!TrainOptions.SelectMax[city]) document.getElementById('max'+city).disabled=true;
        if(document.getElementById('e'+city)) {
         document.getElementById('AsEnabled'+city).checked = TrainOptions.AsEnabled[city];
         document.getElementById('AsTroops'+city).value = TrainOptions.AsTroops[city];
         document.getElementById('AsSelectMax'+city).checked = TrainOptions.AsSelectMax[city];
         if (!TrainOptions.AsSelectMax[city]) document.getElementById('Asmax'+city).disabled=true;
      };
        
        
        
    }
       
    document.getElementById('pbShowTrainHelp').addEventListener('click', function(){
        t.helpPop(this);
    }, false);
       
    document.getElementById('pbAutoTrainState').addEventListener('click', function(){
        t.toggleAutoTrainState(this);
    }, false);

    document.getElementById('pbatTR').addEventListener ('change', function() {
        TrainOptions.tr = this.checked;
        saveTrainOptions();
        }, false);
    document.getElementById('pbatTRset').addEventListener ('change', function() {
        TrainOptions.trset = this.value;
        saveTrainOptions();
        }, false); 
        document.getElementById('pbatDisUnt').addEventListener ('change', function() {
        TrainOptions.DisUnt = this.value;
        saveTrainOptions();
        }, false);

    for(var k=1; k<=Seed.cities.length; k++){
         document.getElementById('treshold'+k).addEventListener('change', function(e){
             if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.Threshold[e.target['className']] = e.target.value;
             saveTrainOptions();
         }, false);
         document.getElementById('SelectMax'+k).addEventListener('change', function(e){
             TrainOptions.SelectMax[e.target['className']] = e.target.checked;
             if (!TrainOptions.SelectMax[e.target['className']]){
                document.getElementById('max'+e.target['className']).value = 0;
                document.getElementById('max'+e.target['className']).disabled=true;
            } else {
                document.getElementById('max'+e.target['className']).disabled=false;
            }
            saveTrainOptions();
         }, false);
         document.getElementById('max'+k).addEventListener('change', function(e){
              TrainOptions.Max[e.target['className']] = e.target.value;
              saveTrainOptions();
          }, false);
         document.getElementById('workers'+k).addEventListener('change', function(e){
              TrainOptions.Workers[e.target['className']] = e.target.value;
              t.AF_TU_Change(e.target['className'],document.getElementById('TroopsCity'+e.target['className']).value);
              TrainOptions.Max[e.target['className']] = document.getElementById('max'+e.target['className']).value;
              saveTrainOptions();
          }, false);
         document.getElementById('Resource'+k).addEventListener('change', function(e){
            TrainOptions.Resource[e.target['className']] = e.target.value;
             saveTrainOptions();
        }, false);
         document.getElementById('TrainSpeed_'+k).addEventListener('change', function(e){
            TrainOptions.Gamble[e.target['className']] = e.target.value;
             saveTrainOptions();
        }, false);
         document.getElementById('TrainSpeedItem_'+k).addEventListener('change', function(e){
            TrainOptions.Item[e.target['className']] = e.target.value;
             saveTrainOptions();
        }, false);
        document.getElementById('SelectCity'+k).addEventListener('change', function(e){
            TrainOptions.Enabled[e.target['className']] = e.target.checked;
            saveTrainOptions();
          }, false);
          document.getElementById('DisTroops'+k).addEventListener('change', function(e){
            TrainOptions.KillTroops[e.target['className']] = e.target.checked;
            saveTrainOptions();
          }, false);  // mac mod
          document.getElementById('autoHgUse'+k).addEventListener('change', function(e){
            TrainOptions.UseHourGlasses[e.target['className']] = e.target.checked;
            saveTrainOptions();
          }, false);  // mac mod autoHgUse
         
          document.getElementById('TroopsCity'+k).addEventListener('change', function(e){
            t.AF_TU_Change(e.target['className'],e.target.value);
            TrainOptions.Troops[e.target['className']] = e.target.value;
              TrainOptions.Max[e.target['className']] = document.getElementById('max'+e.target['className']).value;
            saveTrainOptions();
          }, false);
          document.getElementById('KeepFood'+k).addEventListener('change', function(e){
            if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.Keep[e.target['className']]['Food'] = e.target.value;
            saveTrainOptions();
          }, false);
          document.getElementById('KeepWood'+k).addEventListener('change', function(e){
              if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.Keep[e.target['className']]['Wood'] = e.target.value;
            saveTrainOptions();
          }, false);
          document.getElementById('KeepStone'+k).addEventListener('change', function(e){
            if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.Keep[e.target['className']]['Stone'] = e.target.value;
            saveTrainOptions();
          }, false);
          document.getElementById('KeepOre'+k).addEventListener('change', function(e){
              if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.Keep[e.target['className']]['Ore'] = e.target.value;
            saveTrainOptions();
          }, false);
           if(document.getElementById('AsEnabled'+k)) {  
        document.getElementById('AsEnabled'+k).addEventListener('change', function(e){
            TrainOptions.AsEnabled[e.target['className']] = e.target.checked;
            saveTrainOptions();
          }, false);
         document.getElementById('AsTroops'+k).addEventListener('change', function(e){
             if (isNaN(e.target.value)) e.target.value=0 ;
            TrainOptions.AsTroops[e.target['className']] = e.target.value;
             saveTrainOptions();
         }, false);
                 document.getElementById('Asmax'+k).addEventListener('change', function(e){
              TrainOptions.AsMax[e.target['className']] = e.target.value;
              saveTrainOptions();
          }, false);
            document.getElementById('AsSelectMax'+k).addEventListener('change', function(e){
             TrainOptions.AsSelectMax[e.target['className']] = e.target.checked;
             if (!TrainOptions.AsSelectMax[e.target['className']]){
                document.getElementById('Asmax'+e.target['className']).value = 0;
                document.getElementById('Asmax'+e.target['className']).disabled=true;
            } else {
                document.getElementById('Asmax'+e.target['className']).disabled=false;
            }
            saveTrainOptions();
         }, false);
      };
               
          
          
          
    }
  },
  
  
  helpPop : function (){
    var helpText = '<BR><DL><dt>Autotrain:<dd><LI>Toggle the box in front of the row to enable autotrain for that city (the number is the citynumer).</dd>\
        <dd><LI>Select a trooptype per city in the dropdown boxes.</dd>\
        <dd><LI>Fill in the minimum troops that triggers the autotrain (less then this will not be trained).</dd>\
        <dt>Fill in resources:</dt>\
          <dd><LI>Keep: Autotrain will keep this amount available in the city.</dd>\
          <dd><LI>Use: Autotrain will only use the resources to train troops.</dd>\
        <dt>Turn it on: </dt>\
          <dd><LI>Hit the AutoTrain toggle button.</dd></ul>';
    var pop = new pbPopup ('giftHelp', 0, 0, 550, 230, true);
    pop.centerMe (mainPop.getMainDiv());  
    pop.getMainDiv().innerHTML = helpText;
    pop.getTopDiv().innerHTML = '<CENTER><B>Power Bot '+translate("Help")+'</b>:  '+translate("Auto Train")+'</center>';
    pop.show (true);
  },
  
   
                
  toggleAutoTrainState: function(obj){
    var t = Tabs.AutoTrain;
    if (TrainOptions.Running == true) {
            TrainOptions.Running = false;
            if (document.getElementById('pbAutoTrainState')) {document.getElementById('pbAutoTrainState').value = "Train = OFF";document.getElementById('pbAutoTrainState').setAttribute("class", "buttonDash_OFF");}
        	if (document.getElementById('AutotrainToggle')) {document.getElementById('AutotrainToggle').value = "Train = OFF";document.getElementById('AutotrainToggle').setAttribute("class", "buttonDash_OFF");}
        }
        else {
            TrainOptions.Running = true;
            if (document.getElementById('pbAutoTrainState')) {document.getElementById('pbAutoTrainState').value = "Train = ON";document.getElementById('pbAutoTrainState').setAttribute("class", "buttonDash_ON");}
        	if (document.getElementById('AutotrainToggle')) {document.getElementById('AutotrainToggle').value = "Train = ON";document.getElementById('AutotrainToggle').setAttribute("class", "buttonDash_ON");}
        	t.nextcity();
        }
    saveTrainOptions();
  },
         
  show: function(){
    var t = Tabs.AutoTrain;
  },
  hide: function(){
    var t = Tabs.AutoTrain;
  },
      AF_TU_Change: function(numcity,unit) {
        var t = Tabs.AutoTrain;
        var cityId = Cities.cities[numcity-1].id
        var coutenpop= unsafeWindow.unitcost['unt'+unit][6];
        var X = Seed.citystats['city'+cityId].pop[1];//max pop
        var Y = unsafeWindow.seed.citystats["city"+cityId].pop[3];//workers
        var Q= coutenpop;
        var Z = document.getElementById('workers'+numcity).value/100;
        if (Z == 0)
        document.getElementById("max"+numcity).value=parseIntNan((X-Y)/Q);
        else if (Z == 1)
        document.getElementById("max"+numcity).value=parseIntNan(X/Q);
        else
        document.getElementById("max"+numcity).value = parseIntNan((X-(Y*Z))/Q);
    },
  checkidlepopulation : function(cityId){
    var t = Tabs.AutoTrain;
    
    unitId = TrainOptions.DisUnt;  // 1 sp 2 mm 5 sword    change here   mac mod
    t.max_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[1])).toFixed(0);  //added
    t.cur_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[0])).toFixed(0);  //added
    t.cur_mm = parseInt(Seed.units['city'+cityId]['unt'+unitId]); //added
    num = parseInt(t.max_idle_pop) - parseInt(t.cur_idle_pop);
    
    t.barracks = getCityBuilding(cityId, 13).count;
    t.slots = 0;
    for (k in Seed.queue_unt['city'+cityId])
    if(Seed.queue_unt['city'+cityId][k][7] == false)
    t.slots += 1;
    t.empty = parseInt(t.barracks - t.slots);   // test

     if(parseInt(t.cur_idle_pop) < parseInt(t.max_idle_pop) && parseInt(t.cur_mm) > parseInt(t.max_idle_pop)&& t.empty >1 && TrainOptions.KillTroops[t.city]) // Need to Dismiss MM
      {
          var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
          params.cid = cityId;
          params.type = unitId;
          params.quant = num;
         new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/dismissUnits.php" + unsafeWindow.g_ajaxsuffix,
      {
      method: "post",
      parameters: params,
      onSuccess: function(rslt)
  {
      Seed.units['city'+cityId]['unt'+unitId] -= num;
  },
         });
         
         
           }
           if  (num <500) 
           {
           
          var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
          params.cid = cityId;
          params.type = unitId;
          params.quant = num;
         new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/dismissUnits.php" + unsafeWindow.g_ajaxsuffix,
      {
      method: "post",
      parameters: params,
      onSuccess: function(rslt)
  {
      Seed.units['city'+cityId]['unt'+unitId] -= num;
  },
         });
       
         
           
           }

    
    
    if(TrainOptions.Workers[t.city] == 0)
        t.idle = parseInt(Seed.citystats['city'+cityId].pop[0]) - parseInt(Seed.citystats['city'+cityId].pop[3]);
    else
        t.idle = ((TrainOptions.Workers[t.city]/100)*parseInt(Seed.citystats['city'+cityId].pop[0])).toFixed(0);
    return t.idle>0?true:false;
  },
  checktrainslots : function(cityId,prest){
    var t = Tabs.AutoTrain;
    if(!prest) {
    t.barracks = getCityBuilding(cityId, 13).count;
    t.slots = 0;
    for (k in Seed.queue_unt['city'+cityId])
    if(Seed.queue_unt['city'+cityId][k][7] == false)
    t.slots += 1;
    t.empty = parseInt(t.barracks - t.slots);
    return t.empty>0?true:false;
     } else {
        t.barracks = Number(getCityBuilding(cityId, 22).count + getCityBuilding(cityId, 24).count + getCityBuilding(cityId, 26).count);//24 fey barracks, 22 druid barracks 26 briton barracks
    t.slots = 0;
    for (k in Seed.queue_unt['city'+cityId])
    if(Seed.queue_unt['city'+cityId][k][7] == true)
    t.slots += 1;
    t.empty = parseInt(t.barracks - t.slots);
    return t.empty>0?true:false;
     }
  },
  checkresources : function(cityId){
    var t = Tabs.AutoTrain;
    t.food = parseInt((Seed.resources['city'+cityId].rec1[0]/3600) - TrainOptions['Keep'][t.city]['Food']);
    t.wood = parseInt((Seed.resources['city'+cityId].rec2[0]/3600) - TrainOptions['Keep'][t.city]['Wood']);
    t.stone = parseInt((Seed.resources['city'+cityId].rec3[0]/3600) - TrainOptions['Keep'][t.city]['Stone']);
    t.ore = parseInt((Seed.resources['city'+cityId].rec4[0]/3600) - TrainOptions['Keep'][t.city]['Ore']);
    if(t.food>0 && t.wood>0 && t.stone>0 && t.ore>0){
        return true;
    }
    return false;
  },
  trainamt : function(cityId, unitId){
    var t = Tabs.AutoTrain;
    if(!unitId || unitId<1) return false;
    var cost = unsafeWindow.Object.clone(unsafeWindow.unitcost['unt'+ unitId]);
    var gamble = (parseInt(TrainOptions.Gamble[t.city])>0)?t.gamble[TrainOptions.Gamble[t.city]].cost:1;
    t.amt = Math.floor(t.idle/cost[6]);
    for(var rs=1; rs<5; rs++)
        cost[rs] *= gamble;
    if ((t.food/cost[1]) < t.amt) t.amt = Math.floor(t.food/cost[1]);
    if ((t.wood/cost[2]) < t.amt) t.amt = Math.floor(t.wood/cost[2]);
    if ((t.stone/cost[3]) < t.amt) t.amt = Math.floor(t.stone/cost[3]);
    if ((t.ore/cost[4]) < t.amt) t.amt = Math.floor(t.ore/cost[4]);
    if (unitId < 13) {
    if(TrainOptions.SelectMax[t.city]){
        if(parseInt(t.amt) > parseInt(TrainOptions.Max[t.city])) t.amt = TrainOptions.Max[t.city];
    }
    if(parseInt(t.amt) < parseInt(TrainOptions.Threshold[t.city])) t.amt = 0;
   } else {
      if(TrainOptions.AsSelectMax[t.city])
        if(parseInt(t.amt) > parseInt(TrainOptions.AsMax[t.city])) t.amt = TrainOptions.AsMax[t.city];
      
      if(parseInt(t.amt) < parseInt(TrainOptions.AsTroops[t.city])) t.amt = 0;
   }
    
    return t.amt>0?true:false;
  },
  
  nextcity : function(){
    var t = Tabs.AutoTrain;
    if (!TrainOptions.Running) return;
    if (TrainOptions.tr && TrainOptions.trset != 0) {
        if (Seed.throne.activeSlot != TrainOptions.trset) {
           setTimeout(t.nextcity, 20*1000); //train time lag?
            return;
            };
        };
    t.city++;
    if(t.city > Seed.cities.length) t.city = 1;
    var cityId = Seed.cities[t.city-1][0];
    var idle = t.checkidlepopulation(cityId);
    var resources = t.checkresources(cityId);
    
   
   if(Seed.cityData.city[cityId].isPrestigeCity) {
      var ptrainslots = t.checktrainslots(cityId,true);
      var punit = false;
      if(getCityBuilding(cityId, 22).count)
         punit = 13;
      if(getCityBuilding(cityId, 24).count)
         punit = 14;
      if(getCityBuilding(cityId, 26).count)
         punit = 15;
      if(punit)   
         var ptrain = t.trainamt(cityId, punit);
      if(TrainOptions.AsEnabled[t.city] && idle && ptrainslots && resources && ptrain) {
            t.doTrain(cityId, punit, t.amt, t.nextcity, TrainOptions.Item[t.city]);
           // t.doAutoHour();
            t.city--;
            return;
      };
   };
    var trainslots = t.checktrainslots(cityId);
    var train = t.trainamt(cityId, TrainOptions['Troops'][t.city]);
    
    if(!TrainOptions.Enabled[t.city] || TrainOptions['Troops'][t.city]==0 || !idle || !trainslots || !resources || !train){
        setTimeout(t.nextcity, 5000);
        return;
    }
    t.doTrain(cityId, TrainOptions['Troops'][t.city], t.amt, t.nextcity, TrainOptions.Item[t.city]);
  },
  doTrain : function (cityId, unitId, num, notify, tut){
    var t = Tabs.AutoTrain;
    var time = unsafeWindow.modal_barracks_traintime(unitId, num);
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cityId;
    params.type = unitId;
    params.quant = num;
    if(parseIntNan(tut) > 0)
        params.items = tut;
    if(parseInt(TrainOptions.Gamble[t.city]) > 0)
        params.gambleId = TrainOptions.Gamble[t.city];
   if(params.type < 13)
      var inPrestige = false;
   else var inPrestige = true;
    var profiler = new unsafeWindow.cm.Profiler("ResponseTime", "train.php");
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function(rslt) {
      if (rslt.updateSeed)
        unsafeWindow.update_seed(rslt.updateSeed);
            profiler.stop();
          if (rslt.ok) {
            for (var i = 1; i < 5; i++) {
                var resourceLost = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(num);
                if(rslt.gamble) resourceLost = resourceLost*rslt.gamble[i];
                unsafeWindow.seed.resources["city" + cityId]["rec" + i][0] = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]) - resourceLost;
            }
            unsafeWindow.seed.citystats["city" + cityId].gold[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].gold[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][5]) * parseInt(num);
            unsafeWindow.seed.citystats["city" + cityId].pop[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].pop[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][6]) * parseInt(num);
            unsafeWindow.seed.queue_unt["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, null,inPrestige]);
            setTimeout (notify, 5000);
            for (postcity in Seed.cities) if (Seed.cities[postcity][0] == params.cid) logcity = Seed.cities[postcity][1];
            actionLog(logcity  + ' Train ' + num + ':  ' + troops[unitId] );
          } else {
            setTimeout (notify, 5000);
          }
        },
      onFailure: function () {profiler.stop();}
    });
     
  },
  
  doAutoHour : function (){

    var t = Tabs.AutoTrain;
    var hourglass = 0;
    var sqire =0;
     var knight =0;
     var guen =0;
     var morg =0;
     var arty =0;
     for(var k in unsafeWindow.ksoItems){
         var item = unsafeWindow.ksoItems[k];
         if(item.count > 0 ){
            
            if(item.category == 2){
               if(item.id == 1) sqire++;
               if(item.id == 2) knight++;
               if(item.id == 3) guen++;
               if(item.id == 4) morg++;
               if(item.id == 5) arty++;
               
            }  
         }
      }
      
    t.slots = 0;
    for (k in Seed.queue_unt['city'+cityId]){
    if(Seed.queue_unt['city'+cityId][k][7] == false)
    t.slots += 1;
    }

    for (var i=0;i<=Seed.cities.length;i++){
    if(TrainOptions.UseHourGlasses[i+1]){
     
     var cityId=Seed.cities[i][0]; 
     var hq = Seed.queue_unt['city'+cityId];
     var now = unixTime();
     var tend = Seed.queue_unt['city'+cityId][0][3];
     var ttroop = hq[0][0];
     var hactual = Seed.queue_unt['city'+cityId][0][3]-unixTime();
     var tTime= parseInt(hactual); 
      
           if (tTime > 28500 && arty >10){hourglass = 5;}
           
           if (tTime > 7500 && tTime < 28500 && morg >10){hourglass = 4;}
           
           if (tTime > 3400 && tTime <= 7500 && guen >10){hourglass = 3;}
           
           if (tTime > 700 && tTime <= 3400 && knight > 0){hourglass = 2;}
           
           if (tTime <= 700 && sqire >0){hourglass = 1;}
           
          if (t.slots > 4){  
            
      
             
         if(hourglass > 0 ){
            
         var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.cid = cityId;
        params.iid = hourglass;
        params.uid = ttroop;
        params.apothecary = false;
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/speedupTraining.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
            t.hq.shift()
            var end=parseInt(rslt.dateTraining[i][3]);
           hactual= end-now; 
           
         
           
      },
      onFailure: function (rslt) {
     
      }
    }
    
    ); 
        
       
       }
       }
        // else{}
       
        } 
        }
        
},
       
}

/************************ Gold Collector ************************/
var CollectGold = {
  timer : null,
  lastCollect : {},
      
  init : function (){
    var t = CollectGold;
    for (var c=0; c<Cities.numCities; c++)
      t.lastCollect['c'+ Cities.cities[c].id] = 0;
    if (Options.pbGoldEnable)
      t.setEnable (true);
  },
  
  setEnable : function (tf){
    var t = CollectGold;
    clearTimeout (t.timer);
    if (tf)
      t.tick();
  },

  colCityName : null,
  colHappy : 0,  
  tick : function (){
    var t = CollectGold;
    for (var c=0; c<Cities.numCities; c++){
      var city = Cities.cities[c];
      var happy = Seed.citystats['city'+ city.id].pop[2];
      var since = unixTime() - t.lastCollect['c'+city.id];
      if (happy>=Options.pbGoldHappy && since>15*60){
        t.lastCollect['c'+city.id] = unixTime();
        t.colCityName = city.name;
        t.colHappy = happy;
        t.ajaxCollectGold (city, t.e_ajaxDone);
        break;
      }
    }
    t.timer = setTimeout (t.tick, 15000);    
  },

  e_ajaxDone : function (rslt){
    var t = CollectGold;
    if (rslt.ok)
      actionLog ('Collected '+ rslt.goldGained +' gold for '+ t.colCityName +' (happiness was '+ t.colHappy +')');
    else
      actionLog ('Error collecting gold for '+ t.colCityName +': <SPAN class=boldRed>'+ rslt.errorMsg +'</span>');
  },
  
  ajaxCollectGold : function (city, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = city.id;
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/levyGold.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (notify)  
          notify (rslt);
      },
      onFailure: function (rslt) {
        if (notify)  
          notify (rslt);
      }
    });
  },
}



/************************ Gold Collector ************************/
var CollectGold = {
  timer : null,
  lastCollect : {},
      
  init : function (){
    var t = CollectGold;
    for (var c=0; c<Cities.numCities; c++)
      t.lastCollect['c'+ Cities.cities[c].id] = 0;
    if (Options.pbGoldEnable)
      t.setEnable (true);
  },
  
  setEnable : function (tf){
    var t = CollectGold;
    clearTimeout (t.timer);
    if (tf)
      t.tick();
  },

  colCityName : null,
  colHappy : 0,  
  tick : function (){
    var t = CollectGold;
    for (var c=0; c<Cities.numCities; c++){
      var city = Cities.cities[c];
      var happy = Seed.citystats['city'+ city.id].pop[2];
      var since = unixTime() - t.lastCollect['c'+city.id];
      if (happy>=Options.pbGoldHappy && since>15*60){
        t.lastCollect['c'+city.id] = unixTime();
        t.colCityName = city.name;
        t.colHappy = happy;
        t.ajaxCollectGold (city, t.e_ajaxDone);
        break;
      }
    }
    t.timer = setTimeout (t.tick, 15000);    
  },

  e_ajaxDone : function (rslt){
    var t = CollectGold;
    if (rslt.ok)
      actionLog ('Collected '+ rslt.goldGained +' gold for '+ t.colCityName +' (happiness was '+ t.colHappy +')');
    else
      actionLog ('Error collecting gold for '+ t.colCityName +': <SPAN class=boldRed>'+ rslt.errorMsg +'</span>');
  },
  
  ajaxCollectGold : function (city, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = city.id;
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/levyGold.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (notify) notify (rslt);
      },
      onFailure: function (rslt) {
        if (notify) notify (rslt);
      }
    });
  },
}

/************************ Refresh Every X minutes ************************/
var RefreshEvery  = {
  timer : null,
  PaintTimer : null,
  NextRefresh : 0,
  box : null,
  target : null,
  
  init : function (){
    var t = RefreshEvery;
    t.creatediv();
    if (Options.pbEveryMins < 1) Options.pbEveryMins = 1;
    RefreshEvery.setEnable (Options.pbEveryEnable);
  },
  
  creatediv : function(){
    var t = RefreshEvery;
    t.target = document.getElementById('comm_tabs');
    if(t.target == null){
        setTimeout(t.creatediv, 2000);
        return;
    }
    t.box = document.createElement('div');
    t.target.appendChild(t.box);
  },
  
  setEnable : function (tf){
    var t = RefreshEvery;
    clearTimeout (t.timer);
    if (tf) {
      //t.timer = setTimeout (t.doit, Options.pbEveryMins*60000);
      t.NextRefresh = unixTime() + (Options.pbEveryMins*60);
      t.timer = setTimeout (t.Paint, 1000);
    } else {
        //t.PaintTimer = null;
        t.timer = null;
        t.NextRefresh = 0;
        t.box.innerHTML = '<BR><FONT color=white><B>&nbsp;&nbsp;&nbsp;&nbsp;'+ getMyAlliance()[1] + ' (' + getServerId() +')</b></font>';
    }
  },
  
  doit : function (){
    actionLog ('Refreshing ('+ Options.pbEveryMins +' minutes expired)');
    saveOptions();
    reloadKOC();
  },
  
  setTimer : function (){
    var t = RefreshEvery;
    clearTimeout (t.timer);
    if (Options.pbEveryMins < 1) Options.pbEveryMins = 1;
    RefreshEvery.setEnable (Options.pbEveryEnable);
  },
  
  Paint : function(){
     var t = RefreshEvery;
     if(t.timer == null) return;
     now = unixTime();
     var text = '';
     var Left = parseInt(t.NextRefresh - now);
     var Mouse = unixTime() - Options.MouseMove;
     logit(Mouse);
     if ( Left < 0){
        Left = 0;
        if (Mouse > 500) t.doit();
     }
     if (Left > 60) text = '<BR>&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=white>Next refresh in: <B>'+ timestr(Left) +'</b></font></div>';
     if (Left < 60) text = '<BR>&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=white>Next refresh in: </font><FONT color=red><B>'+ timestr(Left) +'</b></font></div>';
     if (Left==0) text = '<BR>&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=white>Waiting for AFK (5min.)</font></div>';    
     t.box.innerHTML = text;
     t.timer = setTimeout (t.Paint, 1000);
  },
}

/************************ Fairie Killer ************************/
var FairieKiller  = {
  saveFunc : null,
  init : function (tf){
    if (firefoxVersion.substring(0,4) == '4.0b')  // bug in firefox 4.0b10 causes syntax error with: "var func = eval ('function (){}');"
      return;
    FairieKiller.saveFunc = unsafeWindow.Modal.showModalUEP;
    FairieKiller.setEnable (tf);
  },
  setEnable : function (tf){
    if (tf)
      unsafeWindow.Modal.showModalUEP = eval ('function FairieKiller (a,b,c) {actionLog ("Blocked Faire popup");}');
    else
      unsafeWindow.Modal.showModalUEP = FairieKiller.saveFunc;
  },
}

/********** facebook watchdog: runs only in 'http://apps.facebook.com/kingdomsofcamelot/*' instance!  ******/
function facebookWatchdog (){
  var INTERVAL = 50000; // wait 50 seconds minute before checking DOM
  if (!GlobalOptions.pbWatchdog)
    return;
  setTimeout (watchdog, INTERVAL);
  
// TODO: actionLog ?  
  function watchdog (){
    try {
//      if (document.getElementById('app_content_130402594779').firstChild.firstChild.childNodes[1].firstChild.tagName!='IFRAME'){
      if (document.getElementById('app_content_130402594779') == null){
        logit ("KOC NOT FOUND!");
        KOCnotFound(5*60);
      }
    } catch (e){
      logit ("KOC NOT FOUND!");
      KOCnotFound(4*60);
    }
  }
}


function kocWatchdog (){
  var INTERVAL = 10000; // wait 30 seconds before checking DOM
  if (!GlobalOptions.pbWatchdog)
    return;
  setTimeout (watchdog, INTERVAL);
  function watchdog (){
logit ("KOC WATCHDOG: "+ document.getElementById('mod_maparea'));    
    if (document.getElementById('mod_maparea')==null){
      logit ("KOC not loaded");
      KOCnotFound(20);
    }     
  }
}


function KOCnotFound(secs){
  var div;
  var countdownTimer = null;
  var endSecs = (new Date().getTime()/1000) + secs;
    
  div = document.createElement('div');
  div.innerHTML = '<DIV style="font-size:18px; background-color:#a00; color:#fff"><CENTER><BR>'+translate("KOC AIO Script has detected that KOC is not loaded")+'<BR>'+translate("Refreshing in")+' <SPAN id=pbwdsecs></span><BR><INPUT id=pbwdcan type=submit class=pbButton value="'+translate("Cancel Refresh")+'"><BR><BR></div>';
  document.body.insertBefore (div, document.body.firstChild);
  document.getElementById('pbwdcan').addEventListener('click', cancel, false);
  countdown();
      
  function countdown (){
    var secsLeft = endSecs - (new Date().getTime()/1000);
    document.getElementById('pbwdsecs').innerHTML = timestr(secsLeft);
    if (secsLeft < 0) reloadKOC();
    countdownTimer = setTimeout (countdown, 1000);
  }
  function cancel (){
    clearTimeout (countdownTimer);
    document.body.removeChild (div);
  }
}

function searchDOM (node, condition, maxLevel, doMult){
    var found = [];
    eval ('var compFunc = function (node) { return ('+ condition +') }');
    doOne(node, 1);
    if(!doMult){
      if (found.length==0)
        return null;
      return found[0];
    }
    return found;
    function doOne (node, curLevel){
      try {
        if (compFunc(node))
          found.push(node);
      } catch (e){
      }      
      if (!doMult && found.length>0)
        return;
      if (++curLevel<maxLevel && node.childNodes!=undefined)
        for (var c=0; c<node.childNodes.length; c++)
          doOne (node.childNodes[c], curLevel);
    }
  }


var WideScreen = {
  chatIsRight : false,
  useWideMap : false,
  rail : null,
  
  init : function (){
    t = WideScreen;
    if (GlobalOptions.pbWideScreen){
      t.rail = searchDOM (document.getElementById('mod_maparea'), 'node.className=="maparea_rrail"', 10);
      GM_addStyle ('.modalCurtain {width:760px !important} .mod_comm_mmb{z-index:0 !important}');  
      try {
        document.getElementById('progressBar').parentNode.removeChild(document.getElementById('progressBar'));
        document.getElementById('crossPromoBarContainer').parentNode.removeChild(document.getElementById('crossPromoBarContainer'));
      } catch (e) {
      }
    }
  },
        
  setChatOnRight : function (tf){
    t = WideScreen;
    if (tf == t.chatIsRight || !GlobalOptions.pbWideScreen)
      return;
    if (tf){
      var chat = document.getElementById('kocmain_bottom').childNodes[1];
      if (!chat || chat.className!='mod_comm')
        setTimeout (function (){t.setChatOnRight(tf)}, 1000);
      chat.style.top = '-624px';
      chat.style.left = '760px';
      chat.style.height = '720px';
      chat.style.background = 'url("'+ CHAT_BG_IMAGE +'")';
      document.getElementById('mod_comm_list1').style.height = '580px';
      document.getElementById('mod_comm_list2').style.height = '580px';

    } else {
      var chat = document.getElementById('kocmain_bottom').childNodes[1];
      chat.style.top = '0px';
      chat.style.left = '0px';
      chat.style.height = '';
      chat.style.background = '';
      document.getElementById('mod_comm_list1').style.height = '287px';
      document.getElementById('mod_comm_list2').style.height = '287px';
    }
    t.chatIsRight = tf;
  },
  
  useWideMap : function (tf) {
      t = WideScreen;
      if (tf == t.useWideMap || !GlobalOptions.pbWideScreen)
          return;
      if (tf){
      t.rail.style.display = 'none';
      document.getElementById('mapwindow').style.height = "436px";
      document.getElementById('mapwindow').style.width = "1220px";
      document.getElementById('mapwindow').style.zIndex = "50";
      } else {
      t.rail.style.display = 'block';
      document.getElementById('mapwindow').style.height = "439px";
      document.getElementById('mapwindow').style.width = "760px";
      document.getElementById('mapwindow').style.zIndex = "";
      }
  },
}

/*******************   KOC Map interface ****************/
// 0:bog, 10:grassland, 11:lake, 20:woods, 30:hills, 40:mountain, 50:plain, 51:city / barb, 53:misted city
function CMapAjax (){
  this.normalize = normalize;  
  this.request = request;

  function request (left, top, width, notify){    
    var left = parseInt(left / 5) * 5;
    var top = parseInt(top / 5) * 5;
    var width = parseInt((width+4) / 5) * 5;
    
    var blockString = generateBlockList(left, top, width);
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.blocks = blockString;
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) notify(left, top, width, rslt);
        	else actionlog('-------MAP SEARCH ERROR-------')
      },
      onFailure: function (rslt) {
        notify(left, top, width, rslt);
      }
    });
    function generateBlockList (left, top, width) {
      var width5 = parseInt(width / 5);
      var bl = [];
      for (x=0; x<width5; x++){
        var xx = left + (x*5);
        if (xx > 745)
          xx -= 750;
        for (y=0; y<width5; y++){
          var yy = top + (y*5);
          if (yy > 745)
            yy -= 750;
          bl.push ('bl_'+ xx +'_bt_'+ yy);
        }
      }
      return bl.join(",");
    }
  }
 
  function normalize  (x){
    if ( x >= 750)
      x -= 750;
    else if (x < 0)
      x += 750;
    return parseInt (x/5) * 5;
  }
}
  var bypassMulti = {
  MultiBrowserBypass : null,

  init : function (){
      t = bypassMulti;

//      t.MultiBrowserBypass = new CalterUwFunc ('update_seed_ajax', [[/if\(typeof\s*isCancelTraining/im,'var l_lastCallTime = 0; var reload_requests = 0; var l_callIntervalMin = 10; if(typeof isCancelTraining'],[/if\(rslt\.error_code\s*==\s*60\)/im,'return; if(rslt.error_code == 60)']]);
      t.MultiBrowserBypass = new CalterUwFunc ('update_seed_ajax', [[/if\s*\(typeof\s*isCancelTraining/im,'var l_lastCallTime = cm.l_lastCallTime; var reload_requests = cm.reload_requests; var l_callIntervalMin = cm.l_callIntervalMin; if(typeof isCancelTraining'],[/if\s*\(rslt\.error_code\s*==\s*60\)/im,'return; if(rslt.error_code == 60)']]);
      t.MultiBrowserBypass.setEnable(Options.allowMultiBroswer);
  },

  setEnable : function (tf){
	var t = bypassMulti;
	t.MultiBrowserBypass.setEnable (tf);
  },

  isAvailable : function (){
	var t = bypassMulti;
	return t.MultiBrowserBypass.isAvailable();
  }, 

}
var anticd = {
  isInited : false,
  KOCversion : '?',
  
  init: function (){
    if (this.isInited) return this.KOCversion;
    unsafeWindow.cm.cheatDetector.detect = eval ('function a (){}');
    var scripts = document.getElementsByTagName('script');
    for (var i=0; i<scripts.length; i++) if (scripts[i].src.indexOf('camelotmain') >=0) break;   
    if (i<scripts.length){
      var m = scripts[i].src.match (/camelotmain-(.*).js/);  
      if (m) this.KOCversion = m[1];
    }
    this.isInited = true;
    // more coming soon :)
  },
  
  getKOCversion : function (){
    return this.KOCversion;
  },
}
try {
  anticd.init ();
} catch (e){
  logit ("ANTICD error: "+ e);
}

var tabManager = {
  tabList : {},           // {name, obj, div}
  currentTab : null,
  
  init : function (mainDiv){
    var t = tabManager;
    var sorter = [];
    for (k in Tabs){
      if (!Tabs[k].tabDisabled){ 
      	
        t.tabList[k] = {};
        t.tabList[k].name = k;

        t.tabList[k].type = Tabs[k].type;

        t.tabList[k].obj = Tabs[k];
        if (Tabs[k].tabLabel != null)
          t.tabList[k].label = Tabs[k].tabLabel;
        else
          t.tabList[k].label = k;
        if (Tabs[k].tabOrder != null)
          sorter.push([Tabs[k].tabOrder, t.tabList[k]]);
        else
          sorter.push([1000, t.tabList[k]]);
        t.tabList[k].div = document.createElement('div');
      }
    }

    sorter.sort (function (a,b){return a[0]-b[0]});
    var m = '<TABLE cellspacing=2 width=98% class=pbMainTab><TR>';
    for (var i=0; i<sorter.length; i++) {
      if (sorter[i][1].type == 'Tools') var cs = 'notSelTools';
       else var cs = 'notSel';	
      m += '<TD class=spacer></td><TD align=center class='+cs+' id=pbtc'+ sorter[i][1].name +' ><A><SPAN>'+ sorter[i][1].label +'</span></a></td>';
      if ((i+1)%10==0) m+='</tr><TR>';
    }
    m+='</tr></table>';  
    mainPop.getMainTopDiv().innerHTML = m;
    
    for (k in t.tabList) {
      if (t.tabList[k].name == Options.currentTab)
        t.currentTab =t.tabList[k] ;
      document.getElementById('pbtc'+ k).addEventListener('click', this.e_clickedTab, false);
      var div = t.tabList[k].div;
      div.style.display = 'none';
      div.style.height = '100%';
      mainDiv.appendChild(div);
      try {
        t.tabList[k].obj.init(div);
      } catch (e){
        div.innerHTML = "INIT ERROR: "+ e;
      }
    }
    
    if (t.currentTab == null) t.currentTab = sorter[0][1];    
    t.setTabStyle (document.getElementById ('pbtc'+ t.currentTab.name), true, t.currentTab.type);
    t.currentTab.div.style.display = 'block';
  },
  
  hideTab : function (){
    var t = tabManager;
    t.currentTab.obj.hide();
  },
  
  showTab : function (){
    var t = tabManager;
    t.currentTab.obj.show();
  },
    
  setTabStyle : function (e, selected,type){
    if (selected){
    	if (type == 'Tools') e.className = 'selTools';
      	 else e.className = 'sel';
    } else {
    	if (type == 'Tools') e.className = 'notSelTools';
      	 else e.className = 'notSel';
    }
  },
   
  e_clickedTab : function (e,id){
    var t = tabManager;
    if (id) var newTab = t.tabList[id];
     else var newTab = t.tabList[e.target.parentNode.parentNode.id.substring(4)];
    if (t.currentTab.name != newTab.name){
      t.setTabStyle (document.getElementById ('pbtc'+ t.currentTab.name), false, t.currentTab.type);
      t.setTabStyle (document.getElementById ('pbtc'+ newTab.name), true, newTab.type);
      t.currentTab.obj.hide ();
      t.currentTab.div.style.display = 'none';
      t.currentTab = newTab;
      newTab.div.style.display = 'block';
      Options.currentTab = newTab.name;      
    }
    newTab.obj.show();
  },
}

function onUnload (){
  Options.pbWinPos = mainPop.getLocation();
  if (!ResetAll) saveOptions();
}

function mouseMainTab (me){   // right-click on main button resets window location
  if (me.button == 2){
    var c = getClientCoords (document.getElementById('main_engagement_tabs'));
    mainPop.setLocation ({x: c.x+4, y: c.y+c.height});
  }
}

function eventHideShow (){
  if (mainPop.toggleHide(mainPop)){
    tabManager.showTab();
    Options.pbWinIsOpen = true;
  } else {
    tabManager.hideTab();
    Options.pbWinIsOpen = false;
  }
  saveOptions();
}

function hideMe (){
  mainPop.show (false);
  tabManager.hideTab();
  Options.pbWinIsOpen = false;
  saveOptions();
}

function showMe (){
  mainPop.show (true);
  tabManager.showTab();
  Options.pbWinIsOpen = true;
  saveOptions();
}

function addMyFunction (func){      // add function to run in our own scope
  unsafeWindow[func.name] = func;
}

function addunsafeWindowFunction (func){      // add function to run in unsafeWindow's scope
  var scr = document.createElement('script');
    scr.innerHTML = func.toString();
    document.body.appendChild(scr);
}

function alterunsafeWindowFunction (funcName, frArray){
  try {
    funcText = unsafeWindow[funcName].toString();
    rt = funcText.replace ('function '+funcName, 'function');
    for (i=0; i<frArray.length; i++){
      x = rt.replace(frArray[i][0], frArray[i][1]);
      if (x == rt)
        return false;
      rt = x;
    }
    js = funcName +' = '+ rt;
      var scr=document.createElement('script');
      scr.innerHTML=js;
      document.body.appendChild(scr);
      return true;
  } catch (err) {
    return false;
  }
}

function officerId2String (oid){
  if (oid==null)
    return '';
  else if (oid==3)
    return 'Officer';
  else if (oid==2)
    return 'Vice Chance';
  else if (oid==1)
    return 'Chancellor';
  return '';
}

var KnightRoles = [
  ['Foreman', 'politics', 'Pol'],
  ['Marshall', 'combat', 'Com'],
  ['Alchemystic', 'intelligence', 'Int'],
  ['Steward', 'resourcefulness', 'Res'],
];

function officerId2String (oid){
  if (oid==null)
    return '';
  else if (oid==3)
    return 'Officer';
  else if (oid==2)
    return 'Vice Chance';
  else if (oid==1)
    return 'Chancellor';
  return '';
}

var fortNamesShort = {
  53: "Crossbows",
  55: "Trebuchet",
  60: "Trap",
  61: "Caltrops",
  62: "Spiked Barrier",
}

// onClick (city{name, id, x, y}, x, y)   city may be null!
function CdispCityPicker (id, span, dispName, notify, selbut, disable_list){
  function CcityButHandler (t){
    var that = t;
    this.clickedCityBut = clickedCityBut;
    function clickedCityBut (e){
      if (that.selected != null)
        that.selected.className = "castleBut castleButNon";
      that.city = Cities.cities[e.target.id.substr(that.prefixLen)];
      if (that.dispName)
        document.getElementById(that.id+'cname').innerHTML = that.city.name;
      e.target.className = "castleBut castleButSel";
      that.selected = e.target;
      if (that.coordBoxX){
        that.coordBoxX.value = that.city.x;
        that.coordBoxY.value = that.city.y;
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent('change', true, true ); // event type,bubbling,cancelable
        that.coordBoxX.dispatchEvent(evt);
        that.coordBoxY.dispatchEvent(evt);
        that.coordBoxX.style.backgroundColor = '#ffffff';
        that.coordBoxY.style.backgroundColor = '#ffffff';
      }
      if (that.notify != null)
        that.notify(that.city, that.city.x, that.city.y);
    }
  }

  function selectBut (idx){
    document.getElementById(this.id+'_'+idx).click();
  }

  function bindToXYboxes (eX, eY){
    function CboxHandler (t){
      var that = t;
      this.eventChange = eventChange;
      if (that.city){
        eX.value = that.city.x;
        eY.value = that.city.y;
      }
      function eventChange (){
        var xValue=that.coordBoxX.value.trim();
            var xI=/^\s*([0-9]+)[\s|,|-|.]+([0-9]+)/.exec(xValue);                 
            if(xI) {
                that.coordBoxX.value=xI[1]
                that.coordBoxY.value=xI[2]
            }
        var x = parseInt(that.coordBoxX.value, 10);
        var y = parseInt(that.coordBoxY.value, 10);
        if (isNaN(x) || x<0 || x>750){
          that.coordBoxX.style.backgroundColor = '#ff8888';
          return;
        }
        if (isNaN(y) || y<0 || y>750){
          that.coordBoxY.style.backgroundColor = '#ff8888';
          return;
        }
        that.coordBoxX.style.backgroundColor = '#ffffff';
        that.coordBoxY.style.backgroundColor = '#ffffff';
        if (that.notify != null)
          that.notify (null, x, y);
      }
      return false;
    }
    this.coordBoxX = eX;
    this.coordBoxY = eY;
    var bh = new CboxHandler(this);
    eX.maxLength=8;
    eY.maxLength=3;
    eX.style.width='2em';    
    eY.style.width='2em';    
    eX.addEventListener('change', bh.eventChange, false);
    eY.addEventListener('change', bh.eventChange, false);
  }

  this.selectBut = selectBut;
  this.bindToXYboxes = bindToXYboxes;
  this.coordBoxX = null;
  this.coordBoxY = null;
  this.id = id;
  this.dispName = dispName;
  this.prefixLen = id.length+1;
  this.notify = notify;
  this.selected = null;
  this.city = null;
  var m = '';
  for (var i=0; i<Cities.cities.length; i++){
    if(matTypeof(disable_list) == 'array'){
        if(disable_list[i])
            m += '<INPUT class="castleBut castleButNon" id="'+ id +'_'+ i +'" value="'+ (i+1) +'" type=submit DISABLED \>';
        else
            m += '<INPUT class="castleBut castleButNon" id="'+ id +'_'+ i +'" value="'+ (i+1) +'" type=submit \>';
    } else
        m += '<INPUT class="castleBut castleButNon" id="'+ id +'_'+ i +'" value="'+ (i+1) +'" type=submit \>';
  }
  if (dispName)
    m += ' &nbsp; <SPAN style="display:inline-block; width:85px; font-weight:bold;" id='+ id +'cname' +'></span>';
  span.innerHTML = m;
  var handler = new CcityButHandler(this);
  for (var i=0; i<Cities.cities.length; i++)
    document.getElementById (id+'_'+i).addEventListener('click', handler.clickedCityBut, false);
  if (selbut != null)
    this.selectBut(selbut);
};

function setCities(){
  Cities.numCities = Seed.cities.length;
  Cities.cities = [];
  Cities.byID = {};
  for (i=0; i<Cities.numCities; i++){
    city = {};
    city.idx = i;
    city.id = parseInt(Seed.cities[i][0]);
    city.name = Seed.cities[i][1];
    city.x = parseInt(Seed.cities[i][2]);
    city.y = parseInt(Seed.cities[i][3]);
    city.tileId = parseInt(Seed.cities[i][5]);
    city.provId = parseInt(Seed.cities[i][4]);
    getTroopDefTrainEstimates('city'+ city.id, city);
    Cities.cities[i] = city;
    Cities.byID[Seed.cities[i][0]] = city;
  }
}

function getTroopDefTrainEstimates (cityID, city){
    var b = Seed.buildings[cityID];
    city.numCottages = 0;
    city.numBarracks = 0;
    city.maxBarracks = 0;
    city.totLevelsBarracks = 0;
    city.blacksmithLevel = 0;
    city.stableLevel = 0;
    city.workshopLevel = 0;
    city.wallLevel = 0;
    city.feyLevel = 0;
    for (var j=1; j<33; j++){
        if (b['pos'+j]) {
            var bname = parseInt(b['pos'+j][0]);
            var blvl = parseInt(b['pos'+j][1]);
            switch(bname){
                case 13:
                    city.numBarracks++;
                    city.totLevelsBarracks += parseInt(blvl);
                    if (blvl>city.maxBarracks) city.maxBarracks=blvl;
                    break;
                case 5:
                    city.numCottages++;
                    break;
                case 15:
                    city.blacksmithLevel = blvl;
                    break;
                case 16:
                    city.workshopLevel = blvl;
                    break;
                case 17:
                    city.stableLevel = blvl;
                    break;
                case 19:
                    city.wallLevel = blvl;
                    break;
                case 20:
                    city.feyLevel = blvl;
                    break;
            }
        }
    }

    var now = unixTime();
    city.marshallCombatScore = 0;
    var s = Seed.knights[cityID];
    if (s) {
        s = s["knt" + Seed.leaders[cityID].combatKnightId];
        if (s){
            city.marshallCombatScore = s.combat;
            if (s.combatBoostExpireUnixtime > now)
                city.marshallCombatScore *= 1.25;
        }
    }
    city.foremanBasePoliticsScore = 0;
    var s = Seed.knights[cityID];
    if (s) {
        s = s["knt" + Seed.leaders[cityID].politicsKnightId];
        if (s){
            city.foremanBasePoliticsScore = s.politics;
            if (s.politicsBoostExpireUnixtime > now)
                city.foremanBasePoliticsScore *= 1.25;
        }
    }

    city.loggingLevel = parseInt(Seed.tech["tch2"]);
    city.geometryLevel = parseInt(Seed.tech["tch5"]);
    city.eagleEyesLevel = parseInt(Seed.tech["tch6"]);
    city.poisonedEdgeLevel = parseInt(Seed.tech["tch8"]);
    city.metalAlloysLevel = parseInt(Seed.tech["tch9"]);
    city.featherweightPowderLevel = parseInt(Seed.tech["tch10"]);
    city.alloyHorseshoesLevel = parseInt(Seed.tech["tch12"]);
    city.fletchingLevel = parseInt(Seed.tech["tch13"]);
    city.giantsStrengthLevel = parseInt(Seed.tech["tch16"]);

    var bm = city.numBarracks + 0.1 * (city.totLevelsBarracks - city.numBarracks);
    var mf = city.marshallCombatScore / 200;
    var gf = city.geometryLevel / 10;
    var sf = city.stableLevel / 10;
    var wf = city.workshopLevel / 10;
    var isf = bm * (1 + mf + gf);
    var csf = bm * (1 + mf + gf + sf);
    var ssf = bm * (1 + mf + gf + sf + wf);
    var pf = city.foremanBasePoliticsScore / 200;
    var gsf = city.giantsStrengthLevel / 10;
    var dsf = 1 + pf + gsf;

    
    city.Troop1Time = ((city.maxBarracks > 0)?(50/isf):0);
    city.Troop2Time = city.Troop1Time/2;
    city.Troop3Time = ((city.maxBarracks > 1 && city.eagleEyesLevel > 0)?(100/isf):0);
    city.Troop4Time = ((city.maxBarracks > 1 && city.poisonedEdgeLevel > 0)?(150/isf):0);
    city.Troop5Time = ((city.maxBarracks > 2 && city.blacksmithLevel > 0 && city.metalAlloysLevel > 0)?(225/isf):0);
    city.Troop6Time = ((city.maxBarracks > 3 && city.fletchingLevel > 0)?(350/isf):0);
    city.Troop7Time = ((city.maxBarracks > 4 && city.stableLevel > 0 && city.alloyHorseshoesLevel > 0)?(500/csf):0);
    city.Troop8Time = ((city.maxBarracks > 6 && city.blacksmithLevel > 4 && city.stableLevel > 4 && city.alloyHorseshoesLevel > 4)?(1500/csf):0);
    city.Troop9Time = ((city.maxBarracks > 5 && city.stableLevel > 0 && city.workshopLevel > 2 && city.featherweightPowderLevel > 0)?(1000/ssf):0);
    city.Troop10Time = ((city.maxBarracks > 7 && city.stableLevel > 1 && city.workshopLevel > 4 && city.geometryLevel > 4 && city.fletchingLevel > 5)?(3000/ssf):0);
    city.Troop11Time = ((city.maxBarracks > 8 && city.blacksmithLevel > 4 && city.stableLevel > 2 && city.workshopLevel > 6 && city.metalAlloysLevel > 7 && city.geometryLevel > 6)?(4500/ssf):0);
    city.Troop12Time = ((city.maxBarracks > 9 && city.stableLevel > 1 && city.workshopLevel > 8 && city.geometryLevel > 9 && city.fletchingLevel > 9)?(6000/ssf):0);
    city.Def53Time = ((city.wallLevel > 5 && city.blacksmithLevel > 5 && city.fletchingLevel > 4)?(180/dsf):0);
    city.Def55Time = ((city.wallLevel > 7 && city.blacksmithLevel > 7 && city.fletchingLevel > 6 && city.geometryLevel > 6)?(135/dsf):0);
    city.Def60Time = ((city.wallLevel > 3 && city.blacksmithLevel > 3 && city.poisonedEdgeLevel > 1)?(90/dsf):0);
    city.Def61Time = ((city.wallLevel > 0 && city.metalAlloysLevel > 0)?(30/dsf):0);
    city.Def62Time = ((city.wallLevel > 1 && city.blacksmithLevel > 1 && city.loggingLevel > 1)?(60/dsf):0);
}


function dialogRetry (errMsg, seconds, onRetry, onCancel, errCode){
  seconds = parseInt(seconds);
  var pop = new pbPopup ('pbretry', 0, 0, 400,225, true);
  pop.centerMe(mainPop.getMainDiv());
  pop.getTopDiv().innerHTML = '<CENTER>KOC AIO Script</center>';
  pop.getMainDiv().innerHTML = '<CENTER><BR><FONT COLOR=#550000><B>An error has ocurred:</b></font><BR><BR><DIV id=paretryErrMsg></div>\
      <BR><BR><B>Automatically retrying in <SPAN id=paretrySeconds></b></span> seconds ...<BR><BR><INPUT id=paretryCancel type=submit class=pbButton value="CANCEL Retry" \>';
  document.getElementById('paretryCancel').addEventListener ('click', doCancel, false);
  pop.show(false);  // hide errors nit fixed :()
  
  if(errCode && unsafeWindow.g_js_strings.errorcode['err_'+errCode])
    document.getElementById('paretryErrMsg').innerHTML = unsafeWindow.g_js_strings.errorcode['err_'+errCode];
  else
    document.getElementById('paretryErrMsg').innerHTML = errMsg;
  document.getElementById('paretrySeconds').innerHTML = seconds;
  var rTimer = setTimeout (doRetry, seconds*1000);
  countdown ();

  function countdown (){
    document.getElementById('paretrySeconds').innerHTML = seconds--;
    if (seconds > 0)
      cdTimer = setTimeout (countdown, 1000);
  }
  function doCancel(){
    clearTimeout (rTimer);
    clearTimeout (cdTimer);
    pop.destroy();
    onCancel ();
  }
  function doRetry (){
    clearTimeout (rTimer);
    clearTimeout (cdTimer);
    pop.show(false);
    onRetry();
  }
}

function implodeUrlArgs (obj){
  var a = [];
  for (var k in obj)
    a.push (k +'='+ encodeURI(obj[k]) );
  return a.join ('&');    
}

// NOTE: args can be either a string which will be appended as is to url or an object of name->values
function addUrlArgs (url, args){
  if (!args)
    return url;
  if (url.indexOf('?') < 0)
    url += '?';
  else if (url.substr(url.length-1) != '&')
    url += '&';    
  if (matTypeof(args == 'object'))
    return url + implodeUrlArgs (args);    
  return url + args;
}

// emulate protoype's Ajax.Request ...
function AjaxRequest (url, opts){
  RPM++;
  var headers = {
    'X-Requested-With': 'XMLHttpRequest',
    'X-Prototype-Version': '1.6.1',
    'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
  };
  var ajax = null;
  
  if (window.XMLHttpRequest)
    ajax=new XMLHttpRequest();
  else
    ajax=new ActiveXObject("Microsoft.XMLHTTP");
  
  if (opts.method==null || opts.method=='')
    method = 'GET';
  else
    method = opts.method.toUpperCase();  
    
  if (method == 'POST'){
    headers['Content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  } else if (method == 'GET'){
    addUrlArgs (url, opts.parameters);
  }

  ajax.onreadystatechange = function(){
//  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; states 0-4
    if (ajax.readyState==4) {
     if (ajax.status == 500)
        if (opts.onFailure) opts.onFailure(ajax);
      if (ajax.status >= 200 && ajax.status < 305)
        if (opts.onSuccess) opts.onSuccess(ajax);
      else
        if (opts.onFailure) opts.onFailure(ajax);
      
      Options.ResponseSize += parseInt(ajax.getResponseHeader ("Content-Length"));
    } else {
      if (opts.onChange) opts.onChange (ajax);
    }  
  }  
    
  ajax.open(method, url, true);   // always async!


  for (var k in headers)
    ajax.setRequestHeader (k, headers[k]);
  if (matTypeof(opts.requestHeaders)=='object')
    for (var k in opts.requestHeaders)
      ajax.setRequestHeader (k, opts.requestHeaders[k]);
      
  
  if (method == 'POST'){
    var a = [];
    for (k in opts.parameters){
      if(matTypeof(opts.parameters[k]) == 'object')
        for(var h in opts.parameters[k])
            a.push (k+'['+h+'] ='+ opts.parameters[k][h] );
      else
        a.push (k +'='+ opts.parameters[k] );
    }
    ajax.send (a.join ('&'));
  } else               {
    ajax.send();
  }
}   

function AsyncAjaxRequest (url, opts){
 var headers = {
    'X-Requested-With': 'XMLHttpRequest',
    'X-Prototype-Version': '1.6.1',
    'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
  };
  var ajax = null;
  
  if (window.XMLHttpRequest)
    ajax=new XMLHttpRequest();
  else
    ajax=new ActiveXObject("Microsoft.XMLHTTP");
  
  if (opts.method==null || opts.method=='')
    method = 'GET';
  else
    method = opts.method.toUpperCase();  
    
  if (method == 'POST'){
    headers['Content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  } else if (method == 'GET'){
    addUrlArgs (url, opts.parameters);
  }

  ajax.onreadystatechange = function(){
//  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; states 0-4
    if (ajax.readyState==4) {
     if (ajax.status == 500)
        if (opts.onFailure) opts.onFailure(ajax);
      if (ajax.status >= 200 && ajax.status < 305)
        if (opts.onSuccess) opts.onSuccess(ajax);
      else
        if (opts.onFailure) opts.onFailure(ajax);
      
      Options.ResponseSize += parseInt(ajax.getResponseHeader ("Content-Length"));
    } else {
      if (opts.onChange) opts.onChange (ajax);
    }  
  }  
    
  ajax.open(method, url, false);  


  for (var k in headers)
    ajax.setRequestHeader (k, headers[k]);
  if (matTypeof(opts.requestHeaders)=='object')
    for (var k in opts.requestHeaders)
      ajax.setRequestHeader (k, opts.requestHeaders[k]);
      
  
  if (method == 'POST'){
    var a = [];
    for (k in opts.parameters){
      if(matTypeof(opts.parameters[k]) == 'object')
        for(var h in opts.parameters[k])
            a.push (k+'['+h+'] ='+ opts.parameters[k][h] );
      else
        a.push (k +'='+ opts.parameters[k] );
    }
    ajax.send (a.join ('&'));
  } else               {
    ajax.send();
  }
}   

function MyAjaxRequest (url, o, noRetryX){
  RPM++;
  if (DEBUG_TRACE) logit (" 0 myAjaxRequest: "+ url +"\n" + inspect (o, 2, 1));
  var opts = unsafeWindow.Object.clone(o);
  var wasSuccess = o.onSuccess;
  var wasFailure = o.onFailure;
  var retry = 0;
  var delay = 3;
  var show = true;
  var noRetry = noRetry===true?true:false;
  var silentTimer;
  opts.onSuccess = mySuccess;
  opts.onFailure = myFailure;

  new AjaxRequest(url, opts);
  return;

  function myRetry(){
    ++retry;
    
    new AjaxRequest(url, opts);
    delay = delay * 1.25;
  }
  function myFailure(){
    var o = {};
    o.ok = false;
    o.errorMsg = "AJAX Communication Failure";
    wasFailure (o);
  }
  function mySuccess (msg){
    var rslt;
    try {
        rslt = JSON2.parse(msg.responseText);
    } catch(e) {
        if (retry<5) {
            rslt = {"ok":false,"error_code":9,"errorMsg":"Failed due to invalid json"}
        } else {
            rslt = {"ok":true,"error_code":9,"data":[]};
        }
    }
    var x;
    if (window.EmulateAjaxError){
      rslt.ok = false;  
      rslt.error_code=8;
    }
    if (rslt.ok){
      if (rslt.updateSeed)
        unsafeWindow.update_seed(rslt.updateSeed);
      wasSuccess (rslt);
      return;
    }
    rslt.errorMsg = unsafeWindow.printLocalError((rslt.error_code || null), (rslt.msg || null), (rslt.feedback || null));
    if (!noRetry && (rslt.error_code==0 || rslt.error_code==8 || rslt.error_code==1 || rslt.error_code==3)){
      dialogRetry (inspect(rslt.errorMsg), delay, function(){myRetry()}, function(){wasSuccess (rslt)}, rslt.error_code);
    } else if (!noRetry && rslt.error_code==9) {
        silentTimer = setTimeout(silentRetry, delay*100);
    } else {
      wasSuccess (rslt);
    }
  }
  
  function silentRetry() {
    clearTimeout(silentTimer);
    myRetry();
  }
}

function saveOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('Options_'+serverID, JSON2.stringify(Options));}, 0);
}

function saveDashboardOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('DashboardOptions_'+serverID, JSON2.stringify(DashboardOptions));}, 0);
}

function saveTrainOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('TrainOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(TrainOptions));}, 0);
}

function saveCrestOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('CrestOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(CrestOptions));}, 0);
}

function saveCraftOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('CraftOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(CraftOptions));}, 0);
}

function saveApothecaryOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('ApothecaryOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(ApothecaryOptions));}, 0);
}

function saveMarchOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('MarchOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(MarchOptions));}, 0);
}

function saveAtkOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('AtkOptions_' + Seed.player['name'] + '_' +serverID, JSON2.stringify(AtkOptions));}, 0);
}

function saveDFOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('DFOptions' + Seed.player['name'] + '_' +serverID, JSON2.stringify(DFOptions));}, 0);
}
function savemercOptions (){
  var serverID = getServerId();
  setTimeout (function (){GM_setValue ('mercOptions' + Seed.player['name'] + '_' +serverID, JSON2.stringify(mercOptions));}, 0);
}

function saveColors (){
  var serverID = getServerId();
  GM_setValue ('Colors_'+serverID, JSON2.stringify(Colors));
}

function readColors (){
  var serverID = getServerId();
  s = GM_getValue ('Colors_'+serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts)
      Colors[k] = opts[k];
  }else{
	s = GM_getValue ('Colors');
	if (s != null){
		opts = JSON2.parse (s);
		for (k in opts)
		  Colors[k] = opts[k];
	}
  }
  if (Colors.ChatLeaders == "#B8B8B8") {Colors.ChatLeaders = "#B6E7F2";saveColors();}
  if (Colors.ChatVC == "#00ff00") {Colors.ChatVC = "#9ADE78";saveColors();}
  if (Colors.ChatChancy == "#F8E151") {Colors.ChatChancy = "#E9BEED";saveColors();}
}



function readOptions (){
  var serverID = getServerId();
  s = GM_getValue ('Options_'+serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
          Options[k][kk] = opts[k][kk];
      else
        Options[k] = opts[k];
    }
  }
}

function readChatIcons (){
  var serverID = getServerId();
	s = GM_getValue ('ChatIcons'+serverID);
	if (s != null){
		opts = JSON2.parse (s);
		for (k in opts){
			if (ChatIcons[k] != undefined) {
				if (matTypeof(opts[k]) == 'object') {
					for (kk in opts[k])
						if (ChatIcons[k][kk] != undefined)
							ChatIcons[k][kk] = opts[k][kk];
				} else
					ChatIcons[k] = opts[k];
			}
		}
	}
}

function saveChatIcons (){
  var serverID = getServerId();
	GM_setValue ('ChatIcons'+serverID, JSON2.stringify(ChatIcons));
}


function readDashboardOptions (){
  var serverID = getServerId();
  s = GM_getValue ('DashboardOptions_'+serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
          DashboardOptions[k][kk] = opts[k][kk];
      else
        DashboardOptions[k] = opts[k];
    }
  }
}
function readGlobalOptions (){
  GlobalOptions = JSON2.parse (GM_getValue ('Options_??', '{}'));
}

function readApothecaryOptions (){
  var serverID = getServerId();
  s = GM_getValue ('ApothecaryOptions_'+Seed.player['name']+'_'+serverID, '[]');
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
          ApothecaryOptions[k][kk] = opts[k][kk];
      else
        ApothecaryOptions[k] = opts[k];
    }
  }
}

function readDFOptions (){
  var serverID = getServerId();
  s = GM_getValue ('DFOptions'+Seed.player['name']+'_'+serverID, '[]');
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object') for (kk in opts[k]) DFOptions[k][kk] = opts[k][kk];
      else if (DFOptions[k] != undefined) DFOptions[k] = opts[k];
    }
  }
}
function readmercOptions (){
  var serverID = getServerId();
  s = GM_getValue ('mercOptions'+Seed.player['name']+'_'+serverID, '[]');
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object') for (kk in opts[k]) mercOptions[k][kk] = opts[k][kk];
      else if (mercOptions[k] != undefined) mercOptions[k] = opts[k];
    }
  }
}

function readCrestOptions (){
  var serverID = getServerId();
  s = GM_getValue ('CrestOptions_' + Seed.player['name'] + '_' +serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
          CrestOptions[k][kk] = opts[k][kk];
      else
        CrestOptions[k] = opts[k];
    }
  }
}

function readCraftOptions (){
  var serverID = getServerId();
  s = GM_getValue ('CraftOptions_' + Seed.player['name'] + '_' +serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
          CraftOptions[k][kk] = opts[k][kk];
      else
        CraftOptions[k] = opts[k];
    }
  }
}

function readTrainingOptions (){
  var serverID = getServerId();
  s = GM_getValue ('TrainOptions_' + Seed.player['name'] + '_' +serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object') {
      	for (kk in opts[k]) if (TrainOptions[k] != undefined) TrainOptions[k][kk] = opts[k][kk];
      } else if (TrainOptions[k] != undefined) TrainOptions[k] = opts[k];   	
    }
  }
}

function readMarchOptions (){
  var serverID = getServerId();
  s = GM_getValue ('MarchOptions_' + Seed.player['name'] + '_' +serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
            if (matTypeof(opts[k][kk]) == 'object')
                for (kkk in opts[k][kk])
                  MarchOptions_[k][kk][kkk] = opts[k][kk][kkk];
            else
                MarchOptions[k][kk] = opts[k][kk];
      else
        MarchOptions[k] = opts[k];
    }
  }
}


function readAtkOptions (){
  var serverID = getServerId();
  s = GM_getValue ('AtkOptions_' + Seed.player['name'] + '_' +serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts){
      if (matTypeof(opts[k]) == 'object')
        for (kk in opts[k])
            if (matTypeof(opts[k][kk]) == 'object')
                for (kkk in opts[k][kk])
                  AtkOptions_[k][kk][kkk] = opts[k][kk][kkk];
            else
                AtkOptions[k][kk] = opts[k][kk];
      else
        AtkOptions[k] = opts[k];
    }
  }
}


function createButton (label,id){
  var a=document.createElement('a');
  a.className='button20';
  a.id = id;
  a.innerHTML='<span style="color: #ff6;vertical-align:middle">'+ label +'</span>';
  return a;
}

function AddMainTabLink(text, eventListener, mouseListener) {
  var a = createButton (text,'botbutton');
  a.className='tab';
  var tabs=document.getElementById('main_engagement_tabs');
  if(!tabs) {
    tabs=document.getElementById('topnav_msg');
    if (tabs) tabs=tabs.parentNode;
  }
  if (tabs) {
    var e = tabs.parentNode;
    var gmTabs = null;
    for (var i=0; i<e.childNodes.length; i++){
      var ee = e.childNodes[i];
      if (ee.tagName && ee.tagName=='DIV' && ee.className=='tabs_engagement' && ee.id!='main_engagement_tabs'){
        gmTabs = ee;
        break;
      }
    }
    if (gmTabs == null){
      gmTabs = document.createElement('div');
      gmTabs.className='tabs_engagement';
      gmTabs.style.background='#ca5';
      tabs.parentNode.insertBefore (gmTabs, tabs);
      gmTabs.style.whiteSpace='nowrap';
      gmTabs.style.width='735px';
      gmTabs.lang = 'en_PB';
    }
    gmTabs.appendChild(a);
    a.addEventListener('click',eventListener, false);
    if (mouseListener != null)a.addEventListener('mousedown',mouseListener, true);
    return a;
  }
  return null;
}

function AddSubTabLink(text, eventListener, id) {
  var a = createButton (text,'botbutton');
  a.className='tab';
  var tabs=document.getElementById('main_engagement_tabs');
  if(!tabs) {
    tabs=document.getElementById('topnav_msg');
    if (tabs) tabs=tabs.parentNode;
  }
  if (tabs) {
    var e = tabs.parentNode;
    var gmTabs = null;
    for (var i=0; i<e.childNodes.length; i++){
      var ee = e.childNodes[i];
      if (ee.tagName && ee.tagName=='DIV' && ee.className=='tabs_engagement' && ee.id!='main_engagement_tabs'){
        gmTabs = ee;
        break;
      }
    }
    if (gmTabs == null){
      gmTabs = document.createElement('div');
      gmTabs.className='tabs_engagement';
      gmTabs.style.background='#ca5';
      tabs.parentNode.insertBefore (gmTabs, tabs);
      gmTabs.style.whiteSpace='nowrap';
      gmTabs.style.width='735px';
      gmTabs.lang = 'en_PB';
    }
    gmTabs.appendChild(a);
    a.addEventListener('click',eventListener, false);
    if (id != null)
      a.id = id;
    return a;
  }
  return null;
}

function coordLink (x, y){
  var m = [];
  m.push ('(<a onclick="pbGotoMap (');
  m.push (x);
  m.push (',');
  m.push (y);
  m.push ('); return false">');
  m.push (x);
  m.push (',');
  m.push (y);
  m.push ('</a>)');  
  return m.join('');
}


unsafeWindow.pbGotoMap = function (x, y){
  setTimeout (function (){
    document.getElementById('mapXCoor').value = x;
    document.getElementById('mapYCoor').value = y;
    unsafeWindow.reCenterMapWithCoor();
    var a = document.getElementById("mod_views").getElementsByTagName("a");
    for (var b = 0; b < a.length; b++) {
        a[b].className = ""
    }
    document.getElementById('mod_views_map').className = "sel";
    document.getElementById("maparea_city").style.display = 'none';
    document.getElementById("maparea_fields").style.display = 'none';
    document.getElementById("maparea_map").style.display = 'block';
    unsafeWindow.tutorialClear()
  }, 0);
};



/************** ChatPane **********/
var ChatPane = {
  init : function(){
    var t = ChatPane;
  },
  
  HandleChatPane : function() {
    var DisplayName = GetDisplayName();
    var AllianceChatBox=document.getElementById('mod_comm_list2');
    var GlobalChatBox=document.getElementById('mod_comm_list1');
    
    if(AllianceChatBox){
        var chatPosts = document.evaluate(".//div[contains(@class,'chatwrap')]", AllianceChatBox, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
        if(chatPosts){
            for (var i = 0; i < chatPosts.snapshotLength; i++) {
                thisPost = chatPosts.snapshotItem(i);
                if(Options.HelpRequest){
                    var postAuthor = document.evaluate('.//*[@class="nm"]', thisPost, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
                    if(postAuthor.snapshotItem(0)){
                        var postAuthorName = postAuthor.snapshotItem(0).innerHTML;
                        if(postAuthorName != DisplayName){
                            var helpAllianceLinks=document.evaluate(".//a[contains(@onclick,'claimAllianceChatHelp')]", thisPost, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );  
                            if(helpAllianceLinks){
                                for (var j = 0; j < helpAllianceLinks.snapshotLength; j++) {
                                    thisLink = helpAllianceLinks.snapshotItem(j);
                                    var alreadyClicked = thisLink.getAttribute("clicked");
                                    if(!alreadyClicked){
                                        thisLink.setAttribute('clicked', 'true');
                                        var myregexp = /(claimAllianceChatHelp\(.*\);)/;
                                        var match = myregexp.exec(thisLink.getAttribute("onclick"));
                                        
                                        if (match != null) {
                                            onclickCode = match[0];
                                            if(true){
                                            	RPM++
                                                DoUnsafeWindow(onclickCode);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // Hide alliance requests in chat
               if(Options.DeleteRequest){
                     var helpAllianceLinks=document.evaluate(".//a[contains(@onclick,'claimAllianceChatHelp')]", thisPost, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
                    if(helpAllianceLinks){
                        for (var j = 0; j < helpAllianceLinks.snapshotLength; j++) {
                            thisLink = helpAllianceLinks.snapshotItem(j);
                            thisLink.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(thisLink.parentNode.parentNode.parentNode.parentNode);
                        }
                    }
                   
                // Hide alliance reports in chat
                    var myregexp1 = /You are # [0-9]+ of [0-9]+ to help/i;
                    var myregexp2 = /\'s Kingdom does not need help\./i;
                    var myregexp3 = /\'s project has already been completed\./i;
                    var myregexp4 = /\'s project has received the maximum amount of help\./i;
                    var myregexp5 = /You already helped with (.*?)\'s project\./i;
                     var myregexp6 = /Chat Rules:/ ;
                      // var myregexp7 = /\*\./i ;
                     //var myregexp7 = /(.*?) says to the alliance: *:??\<br>\test/ ;  //mac mod hide food req ord bigguns says to the alliance: 4:40

                     //ignore food alert
                    if (thisPost.innerHTML.match(myregexp1) || thisPost.innerHTML.match(myregexp2) || thisPost.innerHTML.match(myregexp3) || thisPost.innerHTML.match(myregexp4) || thisPost.innerHTML.match(myregexp5) || thisPost.innerHTML.match(myregexp6)|| thisPost.innerHTML.contains('is low on food. Remaining:')) {
                        thisPost.parentNode.removeChild(thisPost);
                    }
                }
            }    
        }    
    }
    if (GlobalChatBox) {
    	 var chatPosts = document.evaluate(".//div[contains(@class,'chatwrap')]", GlobalChatBox, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
    	 if(chatPosts) for (var i = 0; i < chatPosts.snapshotLength; i++) {
    	 	 thisPost = chatPosts.snapshotItem(i);
		     if(Options.DeleteRequest){
		            var helpAllianceLinks=document.evaluate(".//a[contains(@onclick,'claimAllianceChatHelp')]", thisPost, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
		            if(helpAllianceLinks){
		                for (var j = 0; j < helpAllianceLinks.snapshotLength; j++) {
		                    thisLink = helpAllianceLinks.snapshotItem(j);
		                    thisLink.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(thisLink.parentNode.parentNode.parentNode.parentNode);
		                }
		            }
		      }
		 }
    }
  },

}


/**********************************************************************************/
function addScript (scriptText){
	var scr = document.createElement('script');   
	scr.innerHTML = scriptText;
	document.body.appendChild(scr);
}
addScript ('uwuwuwFunc = function (text){ eval (text);  }');

var CalterUwFunc = function (funcName, findReplace) {
  var t = this;
  this.isEnabled = false;
  this.isAvailable = isAvailable;
  this.setEnable = setEnable;
  this.funcName = funcName;
  this.funcOld = unsafeWindow[funcName];  
  this.funcNew = null;
  try {
    var funcText = unsafeWindow[funcName].toString();
    var rt = funcText.replace ('function '+ funcName, 'function');
    for (var i=0; i<findReplace.length; i++){
      x = rt.replace(findReplace[i][0], findReplace[i][1]);
      if (x == rt)
        return false;
      rt = x;
    }
    this.funcNew = rt;
  } catch (err) {
  }
      
  function setEnable (tf){
    if (t.funcNew == null)
      return;
    if (t.isEnabled != tf){
      if (tf){
          var scr=document.createElement('script');
          scr.innerHTML = funcName +' = '+ t.funcNew;
          document.body.appendChild(scr);
        setTimeout ( function (){document.body.removeChild(scr);}, 0);
          t.isEnabled = true;
      } else {
        unsafeWindow[t.funcName] = t.funcOld;
        t.isEnabled = false;
      }
    }
  }
  function isAvailable (){
    if (t.funcNew == null)
      return false;
    return true;
  }
};

var CalterUwFuncTools = function (funcName, findReplace) {
  var t = this;
  this.isEnabled = false;
  this.isAvailable = isAvailable;
  this.setEnable = setEnable;
  this.funcOld = null;  
  this.funcNew = null;
  try {
    var x = funcName.split('.');
    var f = unsafeWindow;
    for (var i=0; i<x.length; i++)
      f = f[x[i]];
    ft = f.toString();
    this.funcOld = f;
    var rt = ft.replace ('function '+ funcName, 'function');
    for (var i=0; i<findReplace.length; i++){
      x = rt.replace(findReplace[i][0], findReplace[i][1]);
      if (x == rt)  // if not found
        return;
      rt = x;
    }
    this.funcNew = rt;
  } catch (err) {
  }
      
  function setEnable (tf){
    if (t.funcNew == null) return;
    if (t.isEnabled != tf){
      if (tf){
		unsafeWindow.uwuwuwFunc(funcName +' = '+ t.funcNew);
      	t.isEnabled = true;
      } else {
      var x = funcName.split('.');
      var f = unsafeWindow;
      for (var i=0; i<x.length-1; i++)
        f = f[x[i]];
      f[x[x.length-1]] = this.funcOld;
        t.isEnabled = false;
      }
    }
  }
  function isAvailable (){
    if (t.funcNew == null)
      return false;
    return true;
  }
};

var CalterunsafeWindowVar = function (funcName, findReplace) {
  var t = this;
  this.isEnabled = false;
  this.isAvailable = isAvailable;
  this.setEnable = setEnable;
  this.funcName = funcName;
  this.funcOld = unsafeWindow[funcName];  
  this.funcNew = null;
  try {
    var funcText = null;
    funcName = funcName.split('.');
    funcText = unsafeWindow[funcName[0]];
    for(var i=1; i<funcName.length; i++)
        funcText = funcText[funcName[i]];

    var rt = funcText.toString();
    for (var i=0; i<findReplace.length; i++){
      x = rt.replace(findReplace[i][0], findReplace[i][1]);
      if (x == rt)
        return false;
      rt = x;
    }
    this.funcNew = rt;
  } catch (err) {
    GM_log(err);
  }
  
  function setEnable (tf){
    if (t.funcNew == null)
      return;
    if (t.isEnabled != tf){
      if (tf){
          var scr=document.createElement('script');
          scr.innerHTML = funcName +' = '+ t.funcNew;
          document.body.appendChild(scr);
        setTimeout ( function (){document.body.removeChild(scr);}, 0);
          t.isEnabled = true;
      } else {
        unsafeWindow[t.funcName] = t.funcOld;
        t.isEnabled = false;
      }
    }
  }
  function isAvailable (){
    if (t.funcNew == null)
      return false;
    return true;
  }
};

function getMarchInfo (cityID){
  var ret = {};

  ret.marchUnits = [];
  ret.returnUnits = [];
  ret.resources = [];
  for (i=0; i<=17; i++){
    ret.marchUnits[i] = 0;
    ret.returnUnits[i] = 0;
  }
  for (i=0; i<7; i++){
    ret.resources[i] = 0;
  }
  
  for (k in Seed.queue_atkp[cityID]){   // each march
      march = Seed.queue_atkp[cityID][k];
      if(march.marchType != 5){
          if (typeof (march) == 'object'){
            for (ii=0; ii<=17; ii++){
              ret.marchUnits[ii] += parseInt (march['unit'+ ii +'Count']);
              ret.returnUnits[ii] += parseInt (march['unit'+ ii +'Return']);
            }
            for (ii=1; ii<5; ii++){
              ret.resources[ii] += parseInt (march['resource'+ ii]);
            }
              ret.resources[0] += parseInt (march['gold']);
          }
      }
    }
  return ret;
}

function makeButton20 (label){
  var a = document.createElement('a');
  a.className = "button20 ptButton20";
  var s = document.createElement('span');
  s.innerHTML = label;
  a.appendChild (s);
  return a;
}

function strButton20 (label, tags){
  if (tags == null)
    tags = '';
  return ('<TABLE class=ptNoPad><TR><TD><A class="button20 ptButton20" '+ tags +'><SPAN>'+ label +'</span></a></td></tr></table>' );
}

function strButton14 (label, tags){
  if (tags == null)
    tags = '';
  return ('<A class="button14 ptButton20" '+ tags +'><SPAN>'+ label +'</span></a>' );
}

function reloadKOC (){
  var serverId = getServerId();
  if(serverId == '??') window.location.reload(true);
  var goto = window.location.protocol+'//apps.facebook.com/kingdomsofcamelot/?s='+serverId;
  if(document.URL.match(/standalone=1/i)){
    goto = window.location.protocol+'//www.kabam.com/kingdoms-of-camelot/play?s='+serverId;
  }
  var t = '<FORM target="_top" action="'+ goto +'" method=post><INPUT id=xxpbButReload type=submit class=pbButton value=RELOAD><INPUT type=hidden name=s value="'+ serverId +'"</form>';
  var e = document.createElement ('div');
  e.innerHTML = t;
  document.body.appendChild (e);
  setTimeout (function (){document.getElementById('xxpbButReload').click();}, 0);
}
  
function htmlSelector (valNameObj, curVal, tags){
  var m = [];
  m.push ('<SELECT');
  if (tags){
    m.push (' ');
    m.push (tags);
  }  
  for (var k in valNameObj){
    m.push ('><OPTION ');
    if (k == curVal)
      m.push ('SELECTED ');
    m.push ('value="');
    m.push (k);
    m.push ('">');
    m.push (valNameObj[k]);
    m.push ('</option>');
  }
  m.push ('</select>');
  return m.join ('');
}

function cityStatusString (cs){
  if (cs==4)
    return 'Vacation';
  if (cs==3)
    return 'Truce';
  if (cs==2)
    return 'Beg Protection';
  return 'Normal';
}    

// Simple method, as if it were typed in thru DOM
function sendChat (msg){
  document.getElementById ("mod_comm_input").value = msg;
  unsafeWindow.Chat.sendChat ();
}

// works well, but message is not echoed back to local client
Chat = {
  params : null,

  sendWhisper : function (msg, who, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 3;
    this.params.name = who;
    this._sendit (msg, notify);
  },

  sendGlobal : function (msg, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 1;
    this._sendit (msg, notify);
  },

  sendAlliance : function (msg, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 2;
    this._sendit (msg, notify);
  },

  _sendit : function (msg, notify){
    function strip(s) {
       return s.replace(/^\s+/, '').replace(/\s+$/, '');
    }
    this.params.comment = strip (msg);
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/sendChat.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: this.params,
      onSuccess: function(transport) {
        if (notify)
          notify ();
      },
      onFailure: function(transport) {
        if (notify)
          notify ();
      }
    });
  },
}



/************  LIB classes/functions .... **************/

DebugTimer = {
  startTime : 0,
  start : function (){
    now = new Date();
    DebugTimer.startTime = now.getTime();
  },
  getMillis : function (){
    now = new Date();
    return now.getTime() - DebugTimer.startTime;
  },
  display : function (label, noReset){
    now = new Date();
    elapsed = now.getTime() - DebugTimer.startTime;
    logit (label +": "+ elapsed/1000);
    if (noReset===null || !noReset)
      DebugTimer.startTime = now.getTime();
  },
};


function debugPos  (e){
  return '['+ e.tagName +'] client - offset: '+ e.clientLeft +','+ e.clientTop +','+ e.clientWidth +','+ e.clientHeight
          +' - '+ e.offsetLeft +','+ e.offsetTop +','+ e.offsetWidth +','+ e.offsetHeight +' '+ e +' --OP--> '+ e.offsetParent;
}

function CwaitForElement (id, timeout, notify){
  this.check = check;
  this.end = new Date().getTime() + timeout;
  var t = this;
  this.check();
  function check(){
    if (document.getElementById (id))
      notify (true);
    else if (new Date().getTime() > t.end)
      notify (false);
    else
      setTimeout (t.check, 500);
  }
}

function clickWin (win,obj,evtName) {
    var evt = win.document.createEvent("MouseEvents");
    evt.initMouseEvent(evtName, true, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    return !obj.dispatchEvent(evt);
}
    
function debugElement  (e){
  var x = unsafeWindow.Object.clone (e.wrappedJSObject);
  x.innerHTML = '';
  x.innerText = '';
  x.textContent = '';
  return inspect (x, 1, 1);
}     

function getClientCoords(e){
  if (e==null)
    return {x:null, y:null, width:null, height:null};
  var x=0, y=0;
  ret = {x:0, y:0, width:e.clientWidth, height:e.clientHeight};
  while (e.offsetParent != null){
    ret.x += e.offsetLeft;
    ret.y += e.offsetTop;
    e = e.offsetParent;
  }
  return ret;
}

function DOMtree (e, levels){
  var m = [];
  level (e, levels, 0);
  
  function level (e, levels, cur){
    try {        
      for (var i=0; i<cur; i++)
        m.push('  ');
      if (!e.tagName)
        m.push ('?');
      else
        m.push (e.tagName);
      if (e.id){
        m.push (' id=');
        m.push (e.id);
      }
      if (e.name){
        m.push (' name=');
        m.push (e.name);
      }
      if (e.className){
        m.push (' class=');
        m.push (e.className);
      }
      if (e.style && e.style.display && e.style.display.indexOf('none')>0)
        m.push (' hidden');
       m.push ('\n');
      if (cur < levels){
        for (var c=0; c<e.childNodes.length; c++){
          level (e.childNodes[c], levels, cur+1);
        }
      }
    } catch (e) {
      m.push ('UNAVAILBLE!\n');
    }
  }
  return m.join('');  
}

function parseIntNan (n){
  x = parseInt(n, 10);
  if (isNaN(x))
    return 0;
  return x;
}
function parseIntCommas (n){
  n = n.split(',');
  n = n.join('');
  x = parseInt(n, 10);
  if (isNaN(x))
    return 0;
  return x;
}
function parseIntZero (n){
  n = n.trim();
  if (n == '')
    return 0;
  return parseInt(n, 10);
}
function isNaNCommas (n){
  n = n.split(',');
  n = n.join('');
  return isNaN(n);
}


function getFirefoxVersion (){
  var ver='', i;
  var ua = navigator.userAgent;  
  if (ua==null || (i = ua.indexOf('Firefox/'))<0)
    return;
  return ua.substr(i+8);
}

var WinManager = {
  wins : {},    // prefix : pbPopup obj
  didHide : [],
  
  
  get : function (prefix){
    var t = WinManager;
    return t.wins[prefix];
  },
  
  add : function (prefix, pop){
    var t = WinManager;
    t.wins[prefix] = pop;
    if (unsafeWindow.cpopupWins == null)
      unsafeWindow.cpopupWins = {};
    unsafeWindow.cpopupWins[prefix] = pop;
  },
  
  hideAll : function (){
    var t = WinManager;
    t.didHide = [];
    for (k in t.wins){
      if (t.wins[k].isShown()){
        t.didHide.push (t.wins[k]);
        t.wins[k].show (false);
      }
    }
  },
  restoreAll : function (){
    var t = WinManager;
    for (var i=0; i<t.didHide.length; i++)
      t.didHide[i].show (true);
  },
  
  delete : function (prefix){
    var t = WinManager;
    delete t.wins[prefix];
    delete unsafeWindow.cpopupWins[prefix];
  }    
}


// creates a 'popup' div
// prefix must be a unique (short) name for the popup window
function pbPopup (prefix, x, y, width, height, enableDrag, onClose) {
  var pop = WinManager.get(prefix);
  if (pop){
    pop.show (false);
    return pop;
  }
  this.BASE_ZINDEX = 111111;
    
  // protos ...
  this.show = show;
  this.toggleHide = toggleHide;
  this.getTopDiv = getTopDiv;
  this.getMainTopDiv = getMainTopDiv;
  this.getMainDiv = getMainDiv;
  this.getLayer = getLayer;
  this.setLayer = setLayer;
  this.setEnableDrag = setEnableDrag;
  this.getLocation = getLocation;
  this.setLocation = setLocation;
  this.focusMe = focusMe;
  this.isShown = isShown;
  this.unfocusMe = unfocusMe;
  this.centerMe = centerMe;
  this.destroy = destroy;
  this.autoHeight = autoHeight;

  // object vars ...
  this.div = document.createElement('div');
  this.prefix = prefix;
  this.onClose = onClose;
  
  var t = this;
  this.div.className = 'pbPopup '+ prefix +'_pbPopup';
  this.div.id = prefix +'_outer';
  this.div.style.background = "#fff";
  this.div.style.zIndex = this.BASE_ZINDEX        // KOC modal is 100210 ?
  this.div.style.display = 'none';
  this.div.style.width = width + 'px';
  this.div.style.height = height + 'px';
  this.div.style.maxHeight = height + 'px';
  this.div.style.overflowY = 'show';
  this.div.style.position = "absolute";
  this.div.style.top = y +'px';
  this.div.style.left = x + 'px';
  
  if (pbPopUpTopClass==null)
    topClass = 'pbPopupTop '+ prefix +'_pbPopupTop';
  else
    topClass = pbPopUpTopClass +' '+ prefix +'_'+ pbPopUpTopClass;
    
  var m = '<TABLE cellspacing=0 width=100% ><TR id="'+ prefix +'_bar" class="'+ topClass +'"><TD width=99% valign=bottom><SPAN id="'+ prefix +'_top"></span></td>\
      <TD id='+ prefix +'_X align=right valign=middle onmouseover="this.style.cursor=\'pointer\'" style="color:#fff; background:#333; font-weight:bold; font-size:14px; padding:0px 5px; border-top-right-radius: 25px;">x</td></tr>\
      </table><TABLE cellspacing=0 width=100% ><TR><TD height=100% valign=top class="pbPopMain '+ prefix +'_pbPopMain" colspan=2 id="'+ prefix +'_main"></td></tr></table>';
  document.body.appendChild(this.div);
  this.div.innerHTML = m;
  document.getElementById(prefix+'_X').addEventListener ('click', e_XClose, false);
  this.dragger = new CWinDrag (document.getElementById(prefix+'_bar'), this.div, enableDrag);
  
  this.div.addEventListener ('mousedown', e_divClicked, false);
  WinManager.add(prefix, this);
  
  function e_divClicked (){
    t.focusMe();
  }  
  function e_XClose (){
    t.show(false);
    if (t.onClose != null)
      t.onClose();
  }
  function autoHeight (onoff){
    if (onoff)
      t.div.style.height = '';  
    else
      t.div.style.height = t.div.style.maxHeight;
  }
  function focusMe (){
    t.setLayer(5);
    for (k in unsafeWindow.cpopupWins){
      if (k != t.prefix)
        unsafeWindow.cpopupWins[k].unfocusMe();
    }
  }
  function unfocusMe (){
    t.setLayer(-5);
  }
  function getLocation (){
    return {x: parseInt(this.div.style.left), y: parseInt(this.div.style.top)};
  }
  function setLocation (loc){
    t.div.style.left = loc.x +'px';
    t.div.style.top = loc.y +'px';
  }
  function destroy (){
    document.body.removeChild(t.div);
    WinManager.delete (t.prefix);
  }
  function centerMe (parent){
    if (parent == null){
      var coords = getClientCoords(document.body);
    } else
      var coords = getClientCoords(parent);
    var x = ((coords.width - parseInt(t.div.style.width)) / 2) + coords.x;
    var y = ((coords.height - parseInt(t.div.style.height)) / 2) + coords.y;
    if (x<0)
      x = 0;
    if (y<0)
      y = 0;
    t.div.style.left = x +'px';
    t.div.style.top = y +'px';
  }
  function setEnableDrag (tf){
    t.dragger.setEnable(tf);
  }
  function setLayer(zi){
    t.div.style.zIndex = ''+ (this.BASE_ZINDEX + zi);
  }
  function getLayer(){
    return parseInt(t.div.style.zIndex) - this.BASE_ZINDEX;
  }
  function getTopDiv(){
    return document.getElementById(this.prefix+'_top');
  }
  function getMainDiv(){
    return document.getElementById(this.prefix+'_main');
  }
  function getMainTopDiv(){
      return document.getElementById(this.prefix+'_top');
  }
  function isShown (){
    return t.div.style.display == 'block';
  }
  function show(tf){
    if (tf){
      t.div.style.display = 'block';
      t.focusMe ();
    } else {
      t.div.style.display = 'none';
    }
    return tf;
  }
  function toggleHide(t){
    if (t.div.style.display == 'block') {
      return t.show (false);
    } else {
      return t.show (true);
    }
  }
}

function CWinDrag (clickableElement, movingDiv, enabled) {
  var t=this;
  this.setEnable = setEnable;
  this.setBoundRect = setBoundRect;
  this.debug = debug;
  this.dispEvent = dispEvent;
  this.lastX = null;
  this.lastY = null;
  this.enabled = true;
  this.moving = false;
  this.theDiv = movingDiv;
  this.body = document.body;
  this.ce = clickableElement;
  this.moveHandler = new CeventMove(this).handler;
  this.outHandler = new CeventOut(this).handler;
  this.upHandler = new CeventUp(this).handler;
  this.downHandler = new CeventDown(this).handler;
  this.clickableRect = null;
  this.boundRect = null;
  this.bounds = null;
  this.enabled = false;
  if (enabled == null)
    enabled = true;
  this.setEnable (enabled);

  function setBoundRect (b){    // this rect (client coords) will not go outside of current body
    this.boundRect = boundRect;
    this.bounds = null;
  }

  function setEnable (enable){
    if (enable == t.enabled)
      return;
    if (enable){
      clickableElement.addEventListener('mousedown',  t.downHandler, false);
      t.body.addEventListener('mouseup', t.upHandler, false);
    } else {
      clickableElement.removeEventListener('mousedown', t.downHandler, false);
      t.body.removeEventListener('mouseup', t.upHandler, false);
    }
    t.enabled = enable;
  }

  function CeventDown (that){
    this.handler = handler;
    var t = that;
    function handler (me){
      if (t.bounds == null){
        t.clickableRect = getClientCoords(clickableElement);
        t.bodyRect = getClientCoords(document.body);
        if (t.boundRect == null)
          t.boundRect = t.clickableRect;
        t.bounds = {top:10-t.clickableRect.height, bot:t.bodyRect.height-25, left:40-t.clickableRect.width, right:t.bodyRect.width-25};
      }
      if (me.button==0 && t.enabled){
        t.body.addEventListener('mousemove', t.moveHandler, true);
        t.body.addEventListener('mouseout', t.outHandler, true);
        t.lastX = me.clientX;
        t.lastY = me.clientY;
        t.moving = true;
      }
    }
  }

  function CeventUp  (that){
    this.handler = handler;
    var t = that;
    function handler (me){
      if (me.button==0 && t.moving)
        _doneMoving(t);
    }
  }

  function _doneMoving (t){
    t.body.removeEventListener('mousemove', t.moveHandler, true);
    t.body.removeEventListener('mouseout', t.outHandler, true);
    t.moving = false;
  }

  function CeventOut  (that){
    this.handler = handler;
    var t = that;
    function handler (me){
      if (me.button==0){
        t.moveHandler (me);
      }
    }
  }

  function CeventMove (that){
    this.handler = handler;
    var t = that;
    function handler (me){
      if (t.enabled && !t.wentOut){
        var newTop = parseInt(t.theDiv.style.top) + me.clientY - t.lastY;
        var newLeft = parseInt(t.theDiv.style.left) + me.clientX - t.lastX;
        if (newTop < t.bounds.top){     // if out-of-bounds...
          newTop = t.bounds.top;
          _doneMoving(t);
        } else if (newLeft < t.bounds.left){
          newLeft = t.bounds.left;
          _doneMoving(t);
        } else if (newLeft > t.bounds.right){
          newLeft = t.bounds.right;
          _doneMoving(t);
        } else if (newTop > t.bounds.bot){
          newTop = t.bounds.bot;
          _doneMoving(t);
        }
        t.theDiv.style.top = newTop + 'px';
        t.theDiv.style.left = newLeft + 'px';
        t.lastX = me.clientX;
        t.lastY = me.clientY;
      }
    }
  }

  function debug  (msg, e){
    logit ("*************** "+ msg +" ****************");
    logit ('clientWidth, Height: '+ e.clientWidth +','+ e.clientHeight);
    logit ('offsetLeft, Top, Width, Height (parent): '+ e.offsetLeft +','+ e.offsetTop +','+ e.offsetWidth +','+ e.offsetHeight +' ('+ e.offsetParent +')');
    logit ('scrollLeft, Top, Width, Height: '+ e.scrollLeft +','+ e.scrollTop +','+ e.scrollWidth +','+ e.scrollHeight);
  }

  function dispEvent (msg, me){
    logit (msg + ' Button:'+ me.button +' Screen:'+ me.screenX +','+ me.screenY +' client:'+  me.clientX +','+ me.clientY +' rTarget: '+ me.relatedTarget);
  }
}

function inspect(obj, maxLevels, level, doFunctions){
  var str = '', type, msg;
  if(level == null)  level = 0;
  if(maxLevels == null) maxLevels = 1;
  if(maxLevels < 1)
      return 'Inspect Error: Levels number must be > 0';
  if(obj == null)
    return 'ERROR: Object is NULL\n';
  var indent = '';
  for (var i=0; i<level; i++)
    indent += '  ';
  for(property in obj) {
    try {
        type =  matTypeof(obj[property]);
        if (doFunctions==true && (type == 'function')){
          str += indent + '(' + type + ') ' + property + "[FUNCTION]\n";
        } else if (type != 'function') {
          str += indent + '(' + type + ') ' + property + ( (obj[property]==null)?(': null'):('')) +' = '+ obj[property] +"\n";
        }
        if((type=='object' || type=='array') && (obj[property] != null) && (level+1 < maxLevels))
          str += inspect(obj[property], maxLevels, level+1, doFunctions);  // recurse
    }
    catch(err) {
      // Is there some properties in obj we can't access? Print it red.
      if(typeof(err) == 'string') msg = err;
      else if(err.message)        msg = err.message;
      else if(err.description)    msg = err.description;
      else                        msg = 'Unknown';
      str += '(Error) ' + property + ': ' + msg +"\n";
    }
  }
  str += "\n";
  return str;
}

Array.prototype.compare = function(testArr) {
    if (this.length != testArr.length) return false;
    for (var i = 0; i < testArr.length; i++) {
        if (this[i].compare) {
            if (!this[i].compare(testArr[i])) return false;
        }
        if (this[i] !== testArr[i]) return false;
    }
    return true;
}
String.prototype.StripQuotes = function() {
    return this.replace(/"/g,'');
}

String.prototype.entityTrans = { '&':'&amp;', '<':'&lt;',  '>':'&gt;',  '\"':'&quot;', '\'':'&#039', '<':'\\u003c', '/':'\\/', '\\':'\\\\', '\"':'\\\"','{':'&#123;','}':'&#125;'};
String.prototype.htmlSpecialChars = function() {
  var ret = this.toString();
  for (k in this.entityTrans)
     ret  = ret.split(k).join(this.entityTrans[k]);
  return ret;
}
String.prototype.htmlSpecialCharsDecode = function() {
  var ret = this.toString();
  for (k in this.entityTrans)
     ret = ret.split(this.entityTrans[k]).join(k);
  return ret;
}
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
String.prototype.escape_space = function(){
    var s = this.split(" ");
    for(var i=0; i<s.length; i++)
        s[i] = escape(s[i]);
    //return s.join(" ");
    return this.replace(/</ig,"&#60;");
}
String.prototype.unescape_space = function(){
    var s = this.split(" ");
    for(var i=0; i<s.length; i++)
        s[i] = unescape(s[i]);
    //return s.join(" ");
    return this;
}

function officerId2String (oid){
  if (oid==null)
    return '';
  else if (oid==3)
    return 'Officer';
  else if (oid==2)
    return 'Vice Chance';
  else if (oid==1)
    return 'Chancellor';
  return '';
}

function getResourceProduction (cityId){
  var ret = [0,0,0,0,0];
  var now = unixTime ();
  
  var wilds = [0, 0, 0, 0, 0];
  var w = Seed.wilderness["city" + cityId];
  for (var k in w){
    var type = parseInt(w[k].tileType);
    if (type==10 || type==11)
      wilds[1] += parseInt(w[k].tileLevel);
    else
      wilds[type/10] += parseInt(w[k].tileLevel);
  }  
  
  knight = 0;       
  var s = Seed.knights["city" + cityId];
  if (s) {
    s = s["knt" + Seed.leaders["city" + cityId].resourcefulnessKnightId];
    if (s){
      var knight = parseInt(s.resourcefulness);
      if (s.resourcefulnessBoostExpireUnixtime > now)
        knight *= 1.25;
    }
  }
  var workerFactor = 1;
  var c = parseInt(Seed.citystats["city" + cityId]["pop"][0]);  // Current  population
  var w = parseInt(Seed.citystats["city" + cityId]["pop"][3]);  // Labor force
  if (w > c)
    workerFactor = c / w;
  
  for (var i=1; i<5; i++){
    var usage = Seed.resources["city" + cityId]["rec" + i];
    
    var items = 0;
    if (parseInt(Seed.playerEffects["r" + i + "BstExp"]) > now) {
      items = 0.25;
    }
    var tech = Seed.tech["tch" + i];
    ret[i] = parseInt((usage[2] * (1 + tech/10 + knight/100 + items + 0.05 * wilds[i]) * workerFactor + 100));
  }
  return ret;  
}

function objectName (o){
  var s = o.toString();
  return s.substr(7,s.length-8);
}

function matTypeof (v){
  if (typeof (v) == 'object'){
    if (!v)
      return 'null';
//    else if (unsafeWindow.Object.prototype.toString.apply(v) === '[object Array]')
    else if (v.constructor.toString().indexOf("Array")>=0 && typeof(v.splice)=='function')
      return 'array';
    else return 'object';
  }
  return typeof (v);
}

function updatebotbutton(text, id)
{
    var but=document.getElementById(id);
    but.innerHTML = '<span style="color: #ff6">'+text+'</span>';
}

function tbodyScroller (tbody, maxHeight){  
  tbody.style.maxHeight = '';
  tbody.style.height = '';
  tbody.style.overflowX = 'hidden';
  if (parseInt(tbody.clientHeight) > maxHeight){
    tbody.style.height = maxHeight + 'px';
    tbody.style.maxHeight = maxHeight + 'px';
    tbody.style.overflowY = 'auto';
  }
}
function getRemainingHeight (e, cont){
  var ec = getClientCoords(e);
  var cc = getClientCoords(cont);
  return cont.clientHeight - (ec.y - cc.y);
}

function addCommasInt(n){
  nStr = parseInt(n) + '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(nStr)) {
    nStr = nStr.replace(rgx, '$1' + ',' + '$2');
  }
  return nStr;
}

function addCommas(nStr){
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  }
  return x1 + x2;
}

function unixTime (){
  return parseInt (new Date().getTime() / 1000) + unsafeWindow.g_timeoff;
}
function htmlOptions (a, curVal){
  m = '';
  for (k in a)
    m += '<OPTION value="'+ k +'"'+ (k==curVal?' SELECTED':'')  +'>'+ a[k] +'</option>';
  return m;
}
function getFunctionName (func){
  var name=/\W*function\s+([\w\$]+)\(/.exec(func);
  if (!name)
    return '';
  return name[1];
}

function findAllBetween (txt, find1, find2){
  var m = [];
  var last = 0;
  while ( (i1=txt.indexOf(find1, last))>=0 && (i2=txt.indexOf (find2, i1))>=0 ) {
    m.push (txt.substring(i1+find1.length, i2));
    last = i2 + find2.length;
  }
  return m;
}

function strUpTo (s, find){
  var i = s.indexOf(find);
  if (i > 0)
    return s.substr(0, i);
  return s;
}

/********
 Xd Xh
 Xh Xm
 Xm Xs
 Xs
********/
function timestrShort(time) {
  time = parseInt (time);
  if (time > 86400){
    var m = [];
    time /= 3600;
    m.push (parseInt(time/24));
    m.push ('d ');
    m.push (parseInt(time%24));
    m.push ('h ');
    return m.join ('');    
  } else
    return timestr (time);
}

/**********************
 part       full
 Xd Xh Xm   Xd Xh Xm Xs
 Xh Xm      Xh Xm Xs
 Xm Xs      Xm Xs
 Xs         Xs
**********************/
function timestr(time, full) {
  time = parseInt (time);
  var m = [];
  var t = time;
  if (t < 61)
    return  t + 's';
  if (t > 86400){
    m.push (parseInt(t/86400));
    m.push ('d ');
    t %= 86400;
  }  
  if (t>3600 || time>3600){
    m.push (parseInt(t/3600));
    m.push ('h ');
    t %= 3600;
  }  
  m.push (parseInt(t/60));
  m.push ('m');
  if (full || time<=3600 ){
    m.push (' ');
    m.push (t%60);
    m.push ('s');  
  }
  return m.join ('');
}

/************  LIB singletons .... **************/
// TODO: fix REopening window
var WINLOG_MAX_ENTRIES = 1000;     // TODO
var WinLog = {
  state : null,
  win: null,
  eOut : null,
  lastE : null,
  enabled : true,
  reverse : true,
  busy : false,
isOpening : false,

  open : function (){
    var t = WinLog;

    function eventButClear(){
      var t = WinLog;
      t.lastE = null;
      t.eOut.innerHTML ='';
    }
    function eventButReverse(){
      var t = WinLog;
      if (t.busy)
        return;
      t.busy = true;
      if (t.reverse){
        t.win.document.getElementById('wlRev').value= 'Top';
        t.reverse = false;
      } else{
        t.win.document.getElementById('wlRev').value= 'Bottom';
        t.reverse = true;
      }
      var n = t.eOut.childNodes.length;
      if (n < 2)
        return;
      for (i=n-2; i>=0; i--){
        t.eOut.appendChild (t.eOut.childNodes[i]);
      }
      t.busy = false;
    }
    
    if (!t.win || t.win.closed){
t.isOpening = true;  
// Firefox bug??? It appears as if a new thread is started on open, withOUT reusing same window? huh?
      t.win = window.open('', 'unsafeWindowtrace', 'top=30,left=0,width=900,height=700,scrollbars=no,location=no,menubar=no,directories=no,status=no');
t.isOpening = false;
t.state = null;
    }
    
    if (t.state == null){
      t.win.document.body.innerHTML = '<STYLE>pre{margin:0px} hr{margin:3px; height:1px; border:0px; color:#cee; background-color:#cee}</style>\
        <BODY style="margin:0px; padding:0px; border:none">\
        <DIV id=winlogtop style="background-color:#d0d0d0; margin:0px; padding:0px; border:1px solid">\
        <INPUT id=wlClear type=submit class=pbButton value="Clear"> &nbsp; <INPUT id=wlRev type=submit class=pbButton value="Bottom"></div>\
        <DIV id=wlOut style="overflow-y:auto; height:100%; max-height:100%"></div></body>';
      t.win.document.getElementById('wlClear').addEventListener('click', eventButClear, false);
      t.win.document.getElementById('wlRev').addEventListener('click', eventButReverse, false);
      t.eOut =  t.win.document.getElementById('wlOut');
      t.lastE = null;
      t.state = 1;
    }
  },

  writeText : function (msg){
    var t = WinLog;
    if (!t.enabled || t.isOpening)
      return;
    t.write (msg.htmlSpecialChars());
  },
  
  write : function (msg){
    var t = WinLog;
    if (!t.enabled || t.isOpening)
      return;
    t.open();
    var te = document.createElement('pre');
    var now = new Date();
    var m = [];
    var millis = now.getMilliseconds();
    m.push (now.toTimeString().substring (0,8));
    m.push ('.');
    if (millis<100)
      m.push('0');
    if (millis<10)
      m.push('0');
    m.push(millis);
    m.push (': ');
    m.push (msg);
    te.innerHTML = m.join('');
    if (t.reverse){
      if (t.lastE == null){
        t.eOut.appendChild(te);
        t.lastE = te;
      } else {
        t.eOut.insertBefore(te, t.lastE);
      }
      var hr = document.createElement('hr');
      t.eOut.insertBefore(hr, te);
      t.lastE = hr;
    } else {
      t.eOut.appendChild(te);
      t.eOut.appendChild(document.createElement('hr'));
    }
  },

};

 
/*********************************** Resources TAB ***********************************/
/****
courtDoAction.php
&atype=4&toid=1290791&givercityid=26654
{"ok":true,"gold":500,"resource":500,"resourcetype":"4"}
***/
Tabs.Resources = {
  tabOrder : 100,
  resource : {1:'Food', 2:'Wood', 3:'Stone', 4:'Ore'},
  users : [],
  myDiv : null,
  doList : [], // list of gifts to accept
  accepting : false,
  city : null,
  total : {gold:0, 1:0, 2:0, 3:0, 4:0},
    
  init : function (div){
    var t = Tabs.Resources;
        t.myDiv = div;
    div.innerHTML = '<TABLE cellpadding=0 cellspacing=0 class=pbTab width=100%><TR><TD align=center><INPUT id="pballlist" type=submit class=pbButton value="Fetch User List" \></td></tr></table><HR>';
    div.innerHTML += '<DIV id=resDiv style="width:100%; min-height:300px; height:100%;">';
    document.getElementById('pballlist').addEventListener ('click', t.e_clickfetchlist, false);

  },
  
  show : function (){
  },
  hide : function (){
  },
  
  progress : function (msg, span, add){
    if(add)
        document.getElementById(span).innerHTML+=msg;
    else
        document.getElementById(span).innerHTML=msg;
  },

  e_clickfetchlist : function  (){     // (also cancel accepting)
    var t = Tabs.Resources;
    t.users = [];
    if (t.accepting){
      document.getElementById('pballlist').value = 'Fetch User List';
      document.getElementById('resDiv').innerHTML+= '<BR><SPAN class=boldRed>Cancelled.</span>';
      t.accepting = false;
      return;
    }
    document.getElementById('resDiv').innerHTML = 'Fetching user list ... <span id=pbResUserListCount></span>';
    
    t.fetchUserList (gotUserList);
    function gotUserList(userList){
        if(userList.length < 1){
            listGifts();
            return;
        }
        document.getElementById('resDiv').innerHTML += '<BR>Check if able to collect ... <span id=pbResUserAvailCount></span>';
        t.checkDailyAction(userList, listGifts);
    }
    
    function listGifts (){
      t.city = Cities.cities[0];
      var m = '<DIV class=pbStat><CENTER>User List &nbsp; &nbsp; &nbsp; ('+ t.users.length +' found)</center></div>';
      if (t.users.length<1){
        document.getElementById('resDiv').innerHTML = m + '<BR><BR><CENTER>No users found!</center>';
        return;
      }
      m += '<TABLE class=pbTab align=center><TR><TD align=right>City to apply gifts to: </td><TD id=pbrescityselspan></td></tr>\
          <TR><TD align=right>Select resource to collect</td><TD>'
        + htmlSelector (t.resource, Options.getResType, 'id=pbResColType')
        + '</td></tr><TR><TD>Select users you want to collect from and hit: </td><TD width=250><INPUT type=submit class=pbButton id=pbResDo value="Accept Resources">\
        &nbsp; <SPAN id=pbResNone class=boldRed></span></td></tr></table><HR><TABLE class=pbTab><TR valign=top><TD>\
        <INPUT id=pbResButAll type=submit class=pbButton value="All" style="width:100%; margin-bottom:5px"><BR><INPUT id=pbResButNone type=submit class=pbButton value="None"></td>\
        <TD width=10></td><TD><TABLE align=center cellpadding=0 cellspacing=0 class=pbTabLined>\
        <TBODY id=pbResTbody style="height:250px; overflow:auto; display:block;">\
        <TR style="font-weight:bold; background:white"><TD>Name</td><TD>Might</td><TD width=20></td></tr>';
      for (var i=0; i<t.users.length; i++){
        m += '<TR><TD><INPUT type=checkbox id=pbrchk_'+ i +'> &nbsp;'+ t.users[i].name +'</td><TD>'+ t.users[i].might +'</td></tr>';
      }
      document.getElementById('resDiv').innerHTML = m + '</tbody></table></td></tr></table>';
      new CdispCityPicker ('pbrescitysel', document.getElementById('pbrescityselspan'), true, t.e_CityButton, t.city.idx);
      document.getElementById('pbResDo').addEventListener ('click', t.getErDone, false);
      document.getElementById('pbResButAll').addEventListener ('click', t.e_butAll, false);
      document.getElementById('pbResButNone').addEventListener ('click', t.e_butNone, false);
      // var tbody = document.getElementById('pbResTbody');
      // tbodyScroller (tbody, getRemainingHeight (tbody, mainPop.div));
    }
  },

  e_CityButton : function (city, x, y){
    var t = Tabs.Resources;
    t.city = city;
  },
  
  e_butAll : function (){
    var t = Tabs.Resources;
    for (var i=0; i<t.users.length; i++)
      document.getElementById('pbrchk_'+i).checked = true;
  },
  
  e_butNone : function (){
    var t = Tabs.Resources;
    for (var i=0; i<t.users.length; i++)
      document.getElementById('pbrchk_'+i).checked = false;
  },
  
  getErDone : function (){
    var t = Tabs.Resources;
    t.doList = [];
    document.getElementById('pbResNone').innerHTML = '';
    Options.getResType = document.getElementById('pbResColType').value;
    t.total = {gold:0, 1:0, 2:0, 3:0, 4:0};
    for (var i=0; i<t.users.length; i++){
      if (document.getElementById('pbrchk_'+i).checked)
        t.doList.push (t.users[i]);
    }
    if (t.doList.length==0){
      document.getElementById('pbResNone').innerHTML = 'None Selected!';
      return;
    }
    t.accepting = true;
    document.getElementById('pballlist').value = 'Stop Accepting';
    document.getElementById('resDiv').innerHTML = '<DIV id=rsltDiv style="height:400px; max-height:400px; overflow-y:auto"><B>Accepting from '+ t.doList.length +' users:</b><BR></div>';    
    t.acceptNext ();
  },

    
  allDone : function (msg){
    var t = Tabs.Resources;
    msg += '<BR><BR> Total resources gained : <BR>\
           Gold: '+addCommas(t.total.gold)+'<BR>';
    for(var i=1; i<=4; i++){
        msg += t.resource[i]+': '+addCommas(t.total[i])+'<BR>';
    }
    document.getElementById('rsltDiv').innerHTML += '<BR><BR>' + msg;
    document.getElementById('pballlist').value = 'Fetch User List';
    t.accepting = false;
  },
  
    
  acceptNext : function (){
    var t = Tabs.Resources;
    var gift = t.doList.shift();
    if (gift == null){
      t.allDone ('Done accepting resources.');
      return;
    }
    var acpDiv = document.getElementById('rsltDiv');
    var curDiv = document.createElement ('div');
    acpDiv.appendChild (curDiv);
    curDiv.innerHTML = '<B>From '+ gift.name +': ';    
    var statSpan = document.createElement ('span');
    curDiv.appendChild (statSpan);
    statSpan.innerHTML = 'Accepting... ';
    t.getCourtAction (gift, gotGiftData);
        
    function gotGiftData (rslt){
//logit ("getErDone.gotGiftData ... \n"+ inspect (gift, 8, 1));
      if (!t.accepting)
        return;
      if (rslt.ok){
        var msg = rslt.gold +' gold and '+rslt.resource +' '+ t.resource[rslt.resourcetype]+'&nbsp; &nbsp; OK.';
        actionLog ('Accepted from '+gift.name+': '+ rslt.gold +' gold and '+ rslt.resource +' '+ t.resource[rslt.resourcetype]);
        statSpan.innerHTML += msg;
        t.total.gold += rslt.gold;
        t.total[rslt.resourcetype] += rslt.resource;
        t.acceptNext ();  
        return;
      }
        
      if (rslt.msg)
        msg = '<B>'+ rslt.msg + '</b>';
      else
        msg = '<SPAN class=boldRed>ERROR: '+ rslt.ajaxErr +'</span>';

      curDiv.removeChild (statSpan);
      curDiv = document.createElement ('div');
      curDiv.className = 'indent25';
      acpDiv.appendChild (curDiv);
      curDiv.innerHTML = msg;
      t.acceptNext ();  
    }
    
  },

  getMembersInfo : function (pageNo, notify) {
    var t = Tabs.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pageNo = pageNo;
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
  
  getDailyAction : function (uid, notify){
    var t = Tabs.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pid = uid;
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
  
  getCourtAction : function (gift, notify){
    var t = Tabs.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.atype = Options.getResType;
    params.toid = gift.userId;
    params.givercityid = t.city.id;
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/courtDoAction.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
  
  checkDailyAction : function (userList, notify){
    var t = Tabs.Resources;
    var count = 0;
    t.getDailyAction(userList[count].userId, parseViewCourt);
    
    function parseViewCourt (rslt){
        if (!rslt.ok || rslt.errMsg)
            notify ({errMsg:'Ajax Comm Error'});
        if(rslt.dailyActionFlag == 0)
            t.users.push(userList[count]);
        t.progress(count, 'pbResUserAvailCount');
        count++;
        if(count < userList.length){
            t.getDailyAction(userList[count].userId, parseViewCourt);
        } else {
            notify();
        }
    }
  },
  
  // notify with gifts[] or: {errMsg:xxx}
  fetchUserList : function (notify){
    var t = Tabs.Resources;
    var userList = [];
    t.getMembersInfo(1, parseAlliancePage);
    
    function parseAlliancePage (rslt){
      if (!rslt.ok || rslt.errMsg)
        notify ({errMsg:'Ajax Comm Error'});
      var users = rslt.memberInfo;
      for(var k in users){
        userList.push({userId:users[k].userId, name:users[k].name, might:users[k].prestige, type:'alliance'});
      }
      t.progress(userList.length, 'pbResUserListCount');
      if(rslt.currentPage < rslt.noOfPages){
        t.getMembersInfo((rslt.currentPage+1), parseAlliancePage);
      } else {
        notify(userList);
      }
    }
    
    
  },
}



function addCommasWhole(nStr){
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  }
  return x1;
}

function encode_utf8( s ){
  return unescape( encodeURIComponent( s ) );
}

function decode_utf8( s ){
  return decodeURIComponent( escape( s ) );
}

function CdialogCancelContinue (msg, canNotify, contNotify, centerElement){
  var pop = new pbPopup ('ptcancont', 10, 10, 400,200, true, canNotify);
  if (centerElement)
    pop.centerMe(centerElement);
  else
    pop.centerMe(document.body);
  pop.getTopDiv().innerHTML = '<CENTER>KOC AIO Script</center>';
  pop.getMainDiv().innerHTML = '<TABLE class=pbTab align=center style="height: 100%"><TR align=center height=90%><TD>'+ msg +'</td></tr>\
      <TR align=center><TD><INPUT id=ptok type=submit class=pbButton value="OK" \> &nbsp; &nbsp; </td></tr></table>';
  document.getElementById('ptok').addEventListener ('click', function (){pop.destroy(false); if (canNotify) canNotify();}, false);
  pop.show(true);
}

function CdialogConfirm (msg, canNotify, contNotify, centerElement){
  var pop = new pbPopup ('ptcancont', 10, 10, 400,200, true, canNotify);
  if (centerElement)
    pop.centerMe(centerElement);
  else
    pop.centerMe(document.body);
  pop.getTopDiv().innerHTML = '<CENTER>KOC AIO Script</center>';
  pop.getMainDiv().innerHTML = '<TABLE class=pbTab align=center style="height: 100%"><TR align=center height=90%><TD colspan=2>'+ msg +'</td></tr>\
      <TR align=center><TD><INPUT id=pbok type=submit class=pbButton value="OK" \> &nbsp; &nbsp; </td><TD><INPUT id=pbcancel type=submit class=pbButton value="CANCEL" \> &nbsp; &nbsp; </td></tr></table>';
  document.getElementById('pbok').addEventListener ('click', function (){pop.destroy(false); if (canNotify) canNotify(this);}, false);
  document.getElementById('pbcancel').addEventListener ('click', function (){pop.destroy(false); if (canNotify) canNotify(this);}, false);
  pop.show(true);
}

function hexDump (dat){
  var i = 0;
  var s = [];
  while (i < dat.length) {
    asc = [];
    s.push (hex4(i));
    s.push (': ');
    for (var ii=0; ii<=17; ii++) {
      c = dat.charCodeAt(i+ii);
      s.push (hex2(c));
      s.push (' ');
      if (c>31 && c<128)
        asc.push (dat.charAt(i+ii));
      else
        asc.push ('.');
    }
    s.push ('  ');
    s.push (asc.join(''))
    s.push ('\n');
    i += 16;
  }
  return s.join ('');
  function hex4(d){
    return hexDig(d>>12) + hexDig(d>>8) + hexDig(d>>4) + hexDig(d&15);
  }
  function hex2(d){
    return hexDig(d>>4) + hexDig(d&15);
  }
  function hexDig (d){
    hexdigs = '0123456789ABCDEF';
    return hexdigs.charAt(d&15);    
  }
}
 
// value is 0 to 1.0
function SliderBar (container, width, height, value, classPrefix, margin){
  var self = this;
  this.listener = null;
  if (value==null)
    value = 0;
  if (!margin)
    margin = parseInt(width*.05);
  this.value = value;
  if (width<20) width=20;
  if (height<5) height=5;
  if (classPrefix == null){
    classPrefix = 'slider';
    var noClass = true;
  }    
  var sliderHeight = parseInt(height/2);
  var sliderTop = parseInt(height/4);
  this.sliderWidth = width - (margin*2);
    
  this.div = document.createElement ('div');
  this.div.style.height = height +'px';
  this.div.style.width = width +'px';
  this.div.className = classPrefix +'Cont';
  if (noClass)
    this.div.style.backgroundColor='#ddd';
  
  this.slider = document.createElement ('div');
  this.slider.setAttribute ('style', 'position:relative;');
  this.slider.style.height = sliderHeight + 'px'
  this.slider.style.top = sliderTop + 'px';
  this.slider.style.width = this.sliderWidth +'px';
  this.slider.style.left = margin +'px';   /////
  this.slider.className = classPrefix +'Bar';
  this.slider.draggable = true;
  if (noClass)
    this.slider.style.backgroundColor='#fff';
  
  this.sliderL = document.createElement ('div');
  this.sliderL.setAttribute ('style', 'width:100px; height:100%; position:relative; ');
  this.sliderL.className = classPrefix +'Part';
  this.sliderL.draggable = true;
  if (noClass)
    this.sliderL.style.backgroundColor='#0c0';
  
  this.knob = document.createElement ('div');
  this.knob.setAttribute ('style', 'width:3px; position:relative; left:0px; background-color:#222');
  this.knob.style.height = height +'px';
  this.knob.style.top = (0-sliderTop) +'px';
  this.knob.className = classPrefix +'Knob';
  this.knob.draggable = true;
  this.slider.appendChild(this.sliderL);
  this.sliderL.appendChild (this.knob);
  this.div.appendChild (this.slider);
  container.appendChild (this.div);
  this.div.addEventListener('mousedown',  mouseDown, false);

  this.getValue = function (){
    return self.value;
  }

  this.setValue = function (val){   // todo: range check
    var relX = (val * self.sliderWidth);
    self.sliderL.style.width = relX + 'px';
    self.knob.style.left =  relX + 'px';
    self.value = val;
    if (self.listener)
      self.listener(self.value);
  }
  
  this.setChangeListener = function (listener){
    self.listener = listener;
  }

  function moveKnob (me){
    var relX = me.clientX - self.divLeft;
    if (relX < 0)
      relX = 0;
    if (relX > self.sliderWidth)
      relX = self.sliderWidth;
    self.knob.style.left = (relX - (self.knob.clientWidth/2) ) +'px';   // - half knob width !?!?
    self.sliderL.style.width = relX + 'px';
    self.value =  relX / self.sliderWidth; 
    if (self.listener)
      self.listener(self.value);
  }
  function doneMoving (){
    self.div.removeEventListener('mousemove', mouseMove, true);
    document.removeEventListener('mouseup', mouseUp, true);
  }
  function mouseUp (me){
    moveKnob (me);
    doneMoving();
  }
  
  function mouseDown(me){
    var e = self.slider;
    self.divLeft = 0;
    while (e.offsetParent){   // determine actual clientX
      self.divLeft += e.offsetLeft;
      e = e.offsetParent;
    }
    moveKnob (me);
    document.addEventListener('mouseup',  mouseUp, true);
    self.div.addEventListener('mousemove',  mouseMove, true);
  }
  function mouseMove(me){
    moveKnob (me);
  }
}

function pause(milliseconds) {
    var dt = new Date();
    while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}

function CmatSimpleSound (playerUrl, container, attrs, onLoad, flashVars) {
  var self = this;
  this.player = null;
  this.volume = 100;
  this.isLoaded = false;
  this.onSwfLoaded = null;
  
  var div = document.createElement ('div');
  this.onSwfLoaded = onLoad;
  if (navigator.appName.toLowerCase().indexOf('microsoft')+1) {
    div.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"><param name="movie" value="'+playerUrl+'"><param name="quality" value="high"></object>';
    this.player = div.getElementsByTagName('object')[0];
  } else {
    div.innerHTML = '<embed src="'+playerUrl+'"  bgcolor="#eeeeee" allowfullscreen=false FlashVars="'+ flashVars +'" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>';
    this.player = div.getElementsByTagName('embed')[0].wrappedJSObject;
  }
  if (container)
    container.appendChild (div);
  else
    document.body.appendChild (div);
  for (k in attrs)
    this.player.setAttribute(k, attrs[k]);
       
  this.setVolume = function (chanNum, vol){
    if (!self.isLoaded)
      return;
    self.player.jsSetVolume (chanNum, vol);
    volume = vol;
  }
  
  this.load = function (chanNum, url, bStream, bAutoplay, bUsePolicyFile){   // loop ?
    self.player.jsLoad (chanNum, url, bStream, bAutoplay, bUsePolicyFile);
  }
  
  this.play = function (chanNum, position){
       if (this.isLoaded)
    self.player.jsPlay (chanNum, position);
  }
    
  this.stop = function (chanNum){
       if (this.isLoaded)
    self.player.jsStop (chanNum);
  }
    
  this.getStatus = function (chanNum){           // returns null if sound channel is 'empty'
   if (this.isLoaded)
    return self.player.jsGetStatus (chanNum);
  }
  
  this.debugFunc = function (msg){  // overload to use
  }
      
  this.swfDebug = function (msg){    // called by plugin
    self.debugFunc('SWF: '+ msg);
  }
  this.swfLoaded = function (){    // called by plugin when ready to go!
    self.isLoaded = true;
    self.debugFunc ('playerIsReady');
    if (self.onSwfLoaded)
      self.onSwfLoaded();
  }
  this.swfPlayComplete = function (chanNum){    // called by plugin when a sound finishes playing (overload to be notified)
  }
  this.swfLoadComplete = function (chanNum, isError){    // called by plugin when a sound finishes loading  (overload to be notified)
  }
}
    
function DoUnsafeWindow(func, execute_by_embed) {
    if(this.isChrome || execute_by_embed) {
        var scr=document.createElement('script');
        scr.innerHTML=func;
        document.body.appendChild(scr);
    } else {
        try {
            eval("unsafeWindow."+func);
        } catch (error) {
            logit("A javascript error has occurred when executing a function via DoUnsafeWindow. Error description: "+error.description);
        }
    }
}  

function GetDisplayName(){
    var DisplayName = document.getElementById('topnavDisplayName');
    if(DisplayName){
        DisplayName = DisplayName.innerHTML;
    }else{
        DisplayName = null;
    }
    return DisplayName
}

function DrawLevelIcons() {
	var maptileRe = /modal_maptile.([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)/;
	var mapwindow=document.getElementById('mapwindow');
	if(!mapwindow) return;
	var levelIcons=document.getElementById('levelIcons');
	if(levelIcons) return;
	var ss=document.evaluate(".//a[contains(@class,'slot')]",mapwindow,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
	var idDone=false;
	for(var s=0; s<ss.snapshotLength; s++) {
		var a=ss.snapshotItem(s);
		var onclick=a.getAttribute('id');
		var owner='';
		if(onclick) {
			var tileinfo = unsafeWindow.g_mapObject.model.getTileActions(onclick)["tileClick"];	
			if(tileinfo) {
				var might = tileinfo.might;
				if (might == "--------") might=0;
				var might = parseInt(might)/1000000;
				if (might > 1) might = Math.round(might);
				 else if (might>0) might = might.toFixed(2);
				var alliance = parseIntNan(tileinfo.allianceId);
				var dip = getDiplomacy(alliance);
				owner = tileinfo.username;
				if (owner.length>10) owner = owner.slice(0,10) + '...';
			}
		}
		var sp=a.getElementsByTagName('span');
		if(sp.length==0) continue;

		if(!idDone) { a.id='levelIcons'; idDone=true; }
		var LevelColor = 'black';
		var InfoColor = 'black';

		var Prestige = a.getAttribute('class')
		if (Prestige.indexOf('Prestige') >=0) LevelColor = "#689C00";
		if (Prestige.indexOf('Briton') >=0) LevelColor = "#A944DB";
		if (Prestige.indexOf('Fey') >=0) LevelColor = "#E36600";

		if (tileinfo.type=="city") {
			if (tileinfo.allianceId == null)  InfoColor = '#C4C4C4'; //sp[0].style.color='#57BEFF'; //City unallied -> grey
			if (tileinfo.allianceId != null)  InfoColor = '#F5AF36'; //sp[0].style.color='#FF57B6'; //City allied -> orange
			if (tileinfo.status !="Normal") LevelColor = "white";
		}

		if (tileinfo.type!="city") {				
			if (tileinfo.allianceId != null && tileinfo.tileuserid != null)  LevelColor = InfoColor = '#F5AF36'; //Wild owned allied -> orange
			if (tileinfo.allianceId == null && tileinfo.tileuserid != null && tileinfo.tileuserid != "0" && !tileinfo.mistedflag) LevelColor = InfoColor = '#C4C4C4'; //Wild owned unallied -> grey
			if (tileinfo.mistedflag) LevelColor = InfoColor = '#F5AF36'; //Wild owned misted -> grey
			if (tileinfo.allianceId == null && tileinfo.tileuserid == null && !tileinfo.mistedflag) LevelColor = InfoColor = '#000000	'; //Wild un-owned
		}

		var friendly = hostile = false;
		for (var i in Seed.allianceDiplomacies.friendly) if (Seed.allianceDiplomacies.friendly[i].allianceId == tileinfo.allianceId) friendly = true;
		if (Seed.allianceDiplomacies.allianceId == tileinfo.allianceId) friendly = true;
		for (var i in Seed.allianceDiplomacies.hostile) if (Seed.allianceDiplomacies.hostile[i].allianceId == tileinfo.allianceId) hostile = true;
		if (friendly) InfoColor = '#9ED2FF';
		if (hostile) InfoColor = '#FF5757'

		if (Options.MapShowExtra && unsafeWindow.tvuid!=tileinfo.tileuserid) {
			if (tileinfo.username!="null")
			sp[0].innerHTML = '<B><FONT color="'+LevelColor+'">' + tileinfo.level + '</b></font><FONT color="'+InfoColor+'"> ('+might+ 'M)<br />'+owner + '</font>';
			else
			sp[0].innerHTML = '<FONT color="'+LevelColor+'">' + tileinfo.level + '</font>';
		}
		else if (unsafeWindow.tvuid==tileinfo.tileuserid) {
			if (Prestige.indexOf('city') >=0) LevelColor = "white";
			sp[0].style.color=LevelColor;
		}
	}
}

function AjaxRequest2 (url, opts){
	RPM++;
    var headers = {
        'X-Requested-With': 'XMLHttpRequest',
        'X-Prototype-Version': '1.6.1',
        'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
    };
    var ajax = null; 
    if (window.XMLHttpRequest)
      ajax=new XMLHttpRequest();
    else
      ajax=new ActiveXObject("Microsoft.XMLHTTP"); 
    if (opts.method==null || opts.method=='')
      method = 'GET';
    else
      method = opts.method.toUpperCase();  
    if (method == 'POST'){
        headers['Content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
    } else if (method == 'GET'){
        addUrlArgs (url, opts.parameters);
    }  
    ajax.onreadystatechange = function(){
        // ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; states 0-4
        if (ajax.readyState==4) {
            if (ajax.status >= 200 && ajax.status < 305)
            if (opts.onSuccess) opts.onSuccess(ajax);
            else
                if (opts.onFailure) opts.onFailure(ajax);
            } else {
                if (opts.onChange) opts.onChange (ajax);
            }
    }  
    ajax.open(method, url, true); // always async!
    for (var k in headers)
      ajax.setRequestHeader (k, headers[k]);
     if (matTypeof(opts.requestHeaders)=='object')
          for (var k in opts.requestHeaders)
            ajax.setRequestHeader (k, opts.requestHeaders[k]);
    if (method == 'POST'){
        var a = [];
        for (k in opts.parameters){
              if(matTypeof(opts.parameters[k]) == 'object'){
                  for(var h in opts.parameters[k]){
                      if(matTypeof(opts.parameters[k][h]) == 'object'){
                          for(var i in opts.parameters[k][h]){
                              if(matTypeof(opts.parameters[k][h][i]) == 'object'){
                              for(var j in opts.parameters[k][h][i]){
                                  a.push (k+'['+h+']['+i+']['+j+'] ='+ opts.parameters[k][h][i][j] );
                              }
                              } else
                                  a.push (k+'['+h+']['+i+']'+' ='+ opts.parameters[k][h][i]);
                          }
                      } else
                      a.push (k+'['+h+'] ='+ opts.parameters[k][h] );
                  }
              } else
              a.push (k +'='+ opts.parameters[k] );
        }
        ajax.send (a.join ('&'));
    } else {
        ajax.send();
    }
}

function saveFarmOptions() {
    var serverID = getServerId();
    setTimeout(function () {
        GM_setValue('FarmOptions_' + serverID, JSON2.stringify(FarmOptions));
    }, 0);
}

function readFarmOptions() {
    var serverID = getServerId();
    s = GM_getValue('FarmOptions_' + serverID);
    if (s != null) {
        opts = JSON2.parse(s);
        for (k in opts) {
            if (matTypeof(opts[k]) == 'object') for (kk in opts[k])
            FarmOptions[k][kk] = opts[k][kk];
            else FarmOptions[k] = opts[k];
        }
    }
}

function saveThroneOptions() {
    var serverID = getServerId();
    setTimeout(function () {
        GM_setValue('ThroneOptions_' + serverID, JSON2.stringify(ThroneOptions));
    }, 0);
}

function readThroneOptions() {
    var serverID = getServerId();
    s = GM_getValue('ThroneOptions_' + serverID);
    if (s != null) {
        opts = JSON2.parse(s);
        for (k in opts) {
            if (matTypeof(opts[k]) == 'object') {
            	for (kk in opts[k]) if (ThroneOptions[k] != undefined) ThroneOptions[k][kk] = opts[k][kk];
            } else if (ThroneOptions[k] != undefined) ThroneOptions[k] = opts[k];
        }
    }
}
 
var DeleteReports = {
    deleting : false,
    init : function(){
        var t = DeleteReports;
    },
    
    startdeletereports : function(){
        var t = DeleteReports;
	      if(!t.deleting && (Options.DeleteMsg || Options.DeleteMsgs0 || Options.DeleteMsgs1 || Options.DeleteMsgs2 || Options.DeleteMsgs3 || Options.PlayerFilter.length>0)){
	          t.deleting = true;
	          t.fetchreport(0, t.checkreports);
	      }
    },
    
    fetchreport : function(pageNo, callback){
        var t = DeleteReports;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        if(pageNo > 1) params.pageNo = pageNo;
        
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (rslt) {
                callback(rslt);
            },
                onFailure: function () {
                callback();
            },
        });
    },
    
    checkreports : function(rslt){
        var t = DeleteReports;
        if(!rslt.ok){
            t.deleting = false;
            return;
        }
        if(rslt.arReports.length < 1){
        logit("CR stopped arreports < 1");
            t.deleting = false;
            return;
        }
        var reports = rslt.arReports;
        var totalPages = rslt.totalPages;
        if (rslt.totalPages > 30)
        var totalPages = 30;
        var deletes1 = new Array();
        var deletes0 = new Array();
        for(k in reports){
            if(Options.DeleteMsg){
                if((reports[k].marchType==4 || reports[k].marchType==9) && reports[k].side0PlayerId==0 && reports[k].side0TileType > 50)
                    deletes1.push(k.substr(2));
                else if(reports[k].marchType==1 && t.isMyself(reports[k].side1PlayerId))
                    deletes1.push(k.substr(2));
            }
            if (Options.DeleteMsgs0) if(reports[k].marchType==1 && !t.isMyself(reports[k].side1PlayerId)) deletes0.push(k.substr(2));   
            if (Options.DeleteMsgs1) if((reports[k].side0TileType <= 50 || reports[k].side0TileType==54)&& reports[k].side0PlayerId==0) deletes1.push(k.substr(2));                 
            if (Options.DeleteMsgs2){
            	for (var i=1;i<=Seed.cities.length;i++) {
			    	CityQueue = AtkOptions[i];
			    	for (var y=0;y<CityQueue.length;y++) {
			    		if (reports[k].side0XCoord == CityQueue[y].targetX && reports[k].side0YCoord == CityQueue[y].targetY  && t.isMyself(reports[k].side1PlayerId)) deletes1.push(k.substr(2));
			    	}
			    }
			    if (reports[k].side0XCoord == CrestOptions.X && reports[k].side0YCoord == CrestOptions.Y  && t.isMyself(reports[k].side1PlayerId)) deletes1.push(k.substr(2));
            }
            if (Options.DeleteMsgs3) if (reports[k].marchType == 10) deletes1.push(k.substr(2));
            if (FarmOptions.DeleteReports) {
            	for (i=1;i<=Seed.cities.length;i++){
                    var x=Seed.cities[i-1]["2"];
                    var y=Seed.cities[i-1]["3"];
                    if (Tabs.farm.FarmArray[i]) for (j=0;j<Tabs.farm.FarmArray[i].length;j++) if (reports[k].side1XCoord == x && reports[k].side1YCoord == y && reports[k].side0XCoord == Tabs.farm.FarmArray[i][j]["x"] && reports[k].side0YCoord == Tabs.farm.FarmArray[i][j]["y"]) deletes1.push(k.substr(2));
                	
            	}	    
            }
        }
        for (var i=0;i<Options.PlayerFilter.length;i++) if (Options.PlayerFilter[i]['uid']==reports[k].side1PlayerId) deletes1.push(k.substr(2));
        if(deletes1.length > 0 || deletes0.length > 0){
            t.deleteCheckedReports(deletes1, deletes0);
        } else {
            t.deleting = false;
            return;
        }
    },
    
    deleteCheckedReports : function(deletes1, deletes0){
        var t = DeleteReports;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.s1rids = deletes1.join(",");
        params.s0rids = deletes0.join(",");
        params.cityrids = '';
        
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (rslt) {
                if(rslt.ok){
                    Seed.newReportCount = parseInt(Seed.newReportCount) - parseInt(deletes1.length) - parseInt(deletes0.length);
                }
                t.fetchreport(0, t.checkreports);
            },
            onFailure: function () {
            },
        });
    },
    
    isMyself: function(userID){
        var t = DeleteReports;
        if(!Seed.players["u"+userID])
            return false;
        if(Seed.players["u"+userID].n == Seed.player.name)
            return true;
        else
            return false;
        return false;
    },
}

/******************* Apothecary Tab **********************/
Tabs.Apothecary = {
  tabOrder : 591,                    
  tabDisabled : false, 
  tabLabel : 'Apothecary',           
  cities : [],
  pop : null,
  pop2 : null,
  myDiv : null,
  timer : null,
  city : 0,
  
  init : function (div){
    var t = Tabs.Apothecary;
    t.myDiv = div;
    var n = '<DIV class=pbStat >APOTHECARY TAB</div><table width=100% height=0% class=pbTab><tr align=center >';
    n += '<td><input class="buttonDash_'+ (ApothecaryOptions.Active?'ON':'OFF') +'" type=submit id=pbapothecary_power value="Auto Heal = '+(ApothecaryOptions.Active?'ON':'OFF')+'" /></td></tr></table>';
    n += '<DIV class=pbStat >WOUNDED UNITS</div><DIV id= showTroops></div>';
    n += '<DIV class=pbStat >UNITS REVIVING</div><DIV id=showInfo></div>';
    div.innerHTML = n;
    document.getElementById('pbapothecary_power').addEventListener('click', function(){t.e_toggleswitch(this);},false);
    t.paintStats();
    t.loop();
  },

  paintStats : function (){
    var t = Tabs.Apothecary;
    var time = 0;
    var now = unixTime();
    var troop = 0;
    var amount = 0;

    var n='<TABLE class=pbTabOverview cellpadding=0 cellspacing=0><TR><TD style="background: #FFFFFF; vertical-align:top;"></td>';
    for(i=0; i<Cities.numCities; i++) n += "<TD width=81 style='background: #FFFFFF'><B>"+ Cities.cities[i].name.substring(0,11) +"</b></td>";
    n+="</tr>";
   	for(a=1;a<=17;a++) {
		n+='<TR><TD style="background: #FFFFFF; vertical-align:top;">'+ unsafeWindow.unitcost['unt'+a][0]+'</td>';
   	    for(b=0; b<Cities.numCities; b++) {
   	       	if (Seed.woundedUnits['city' + Seed.cities[b][0]]['unt'+a] > 0) n+= '<TD align=right >'+addCommas(Seed.woundedUnits['city' + Seed.cities[b][0]]['unt'+a])+'</td>';
   	        else n+='<TD></td>';
   	    }
   	}
   	n+='<TR><TD></td></table>';
    document.getElementById('showTroops').innerHTML = n;     
    var o = '<TABLE class=pbTabOverview cellpadding=0 cellspacing=0><TR><TD width="100px"></td><TD width="200px">Troops</td><TD width="150px">Time</td></tr>';
    for(b=0;b<Cities.numCities;b++) {
     	if (t.CheckApothecary(Seed.cities[b][0])) var color = "black";
     	else var color = "red";
     	o += '<TR><TD><FONT color='+ color+'>' + Seed.cities[b][1] +':</font></td>';
     	troop = 0;
     	amount = 0;
     	if (Seed.queue_revive['city' + Seed.cities[b][0]][0] != undefined) {
     		troop  = Seed.queue_revive['city' + Seed.cities[b][0]][0][0];
     		amount = Seed.queue_revive['city' + Seed.cities[b][0]][0][1];
     	}	
     	if (amount > 0 && troop > 0) o+= '<TD>' + amount + ' ' + troops[troop] + '</td>';
     	else o+='<TD>&nbsp</td>';
     	time = 0;
     	if (Seed.queue_revive['city' + Seed.cities[b][0]][0] != undefined) time = Seed.queue_revive['city' + Seed.cities[b][0]][0][3] - now;   	
     	if (time > 0) { 
     		o+= '<TD align=right >'+timestr(time) + ' ';	 
     		time = 0;
     		if (Seed.queue_revive['city' + Seed.cities[b][0]][0] != undefined) time = Seed.queue_revive['city' + Seed.cities[b][0]][0][3] - Seed.queue_revive['city' + Seed.cities[b][0]][0][2];
     		o+= '(' + timestr(time) + ')</td>';
     	} else o+='<TD>&nbsp</td>';

     	o += '<TD>&nbsp</td>';
    }   
    o+='</tr></table>';  
    document.getElementById('showInfo').innerHTML = o;    
  },

  CheckApothecary : function(cityId){
    var t = Tabs.Apothecary;
    var check = false;
    for (k in Seed.buildings['city' + cityId]) if (Seed.buildings['city' + cityId][k][0] == 21 || Seed.buildings['city' + cityId][k][0] == 23) check= true;	   
  	return check;
  },

  loop : function(){
    var t = Tabs.Apothecary;
    if(!ApothecaryOptions.Active) return;
    var now = unixTime();
    for(b=0;b<Cities.numCities;b++) {
    	if (Seed.queue_revive['city' + Seed.cities[b][0]][0] != undefined) if (now > Seed.queue_revive['city' + Seed.cities[b][0]][0][3]) Seed.queue_revive['city' + Seed.cities[b][0]].splice(0,1); 
     	if (t.CheckApothecary(Seed.cities[b][0]) &&  Seed.queue_revive['city' + Seed.cities[b][0]].length == 0)  for(a=17;a>=1;a--) if (Seed.woundedUnits['city' + Seed.cities[b][0]]['unt'+a] > 0) setTimeout(t.do_revive, (1000*(b+1)),Seed.cities[b][0],a,Seed.woundedUnits['city' + Seed.cities[b][0]]['unt'+a]);
	}    	
  },
  
  e_toggleswitch : function(obj){
    var t = Tabs.Apothecary;
    if(ApothecaryOptions.Active){
        if (document.getElementById('pbapothecary_power')) {document.getElementById('pbapothecary_power').value = "Auto Heal = OFF";document.getElementById('pbapothecary_power').setAttribute("class", "buttonDash_OFF");}
        if (document.getElementById('ApothecaryToggle')) {document.getElementById('ApothecaryToggle').value = "Auto Heal = OFF";document.getElementById('ApothecaryToggle').setAttribute("class", "buttonDash_OFF");}
        ApothecaryOptions.Active = false;
    } else {
        if (document.getElementById('pbapothecary_power')) {document.getElementById('pbapothecary_power').value = "Auto Heal = ON";document.getElementById('pbapothecary_power').setAttribute("class", "buttonDash_ON");}
        if (document.getElementById('ApothecaryToggle')) {document.getElementById('ApothecaryToggle').value = "Auto Heal = ON";document.getElementById('ApothecaryToggle').setAttribute("class", "buttonDash_ON");}
        ApothecaryOptions.Active = true;
    }
    saveApothecaryOptions();
  },

  do_revive : function(currentcityid,unitId,num){
    var t = Tabs.Apothecary;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = currentcityid;
    params.type = unitId;
    params.apothecary = true;
    var time = unsafeWindow.cm.RevivalModel.getRevivalStats(unitId, num).time;
    if (time > 3600) params.quant =  Math.round(3600 / (time/num));
     else params.quant = num;
    time = unsafeWindow.cm.RevivalModel.getRevivalStats(unitId, params.quant).time;
    
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function(transport) {
          var rslt=eval("("+transport.responseText+")");
          if (rslt.ok) {
            for (var i = 1; i < 5; i++) {
                var resourceLost = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(params.quant);
                if(rslt.gamble) resourceLost = resourceLost*rslt.gamble[i];
                Seed.resources["city" + params.cid]["rec" + i][0] = parseInt(Seed.resources["city" + params.cid]["rec" + i][0]) - resourceLost;
            }
            if (!rslt.initTS) rslt.initTS = unixTime() - 1;         
            Seed.queue_revive["city" + params.cid].push([unitId, params.quant, rslt.initTS, parseInt(rslt.initTS) + time, time, time, null]);        
  	        var cost = unsafeWindow.cm.RevivalModel.getRevivalStats(unitId, params.quant).cost;
            Seed.woundedUnits["city" + params.cid]["unt"+params.type]-= params.quant;
            Seed.citystats["city" + params.cid].gold[0] -= parseInt(cost);
            for (postcity in Seed.cities) if (Seed.cities[postcity][0] == params.cid) logcity = Seed.cities[postcity][1];
            actionLog('Revived: ' + params.quant + ' ' + troops[params.type]+ ' in ' + logcity);
            t.paintStats();
          }
        },
      onFailure: function () {}
    });
  },
  
  hide : function (){
    var t = Tabs.Apothecary;
    clearInterval(t.timer);
  },
  
  show : function (){
    var t = Tabs.Apothecary;
    t.timer = setInterval(t.paintStats,1000);
  },
}

/****************************  Population Control Tab  ******************************/
Tabs.popcontrol = {
  tabOrder : 850,
  tabDisabled : false,
  tabLabel : unsafeWindow.g_js_strings.commonstr.population,
  myDiv : null,
  timer : null,
  timer_del : null,
  timer_cycle : null,
   del_count : 0,
   cycle_running : false,
   busy : false,
   cycle_step : 0,

  logtable : null,
  logmaxEntries: 300,
  loglast99 : [],
  poptab_troop_dismiss : 1,
  last_ran : 'train',


  init : function (div)
   {
      var t = Tabs.popcontrol;
      t.myDiv = div;
      var selbut=0;
      
      var m = '<DIV class=pbStat>Population Control</div>';

      m += '<table border=0 width="100%">';  
      m += '<tr align=center>';
      m += '<td align=left><input type=submit id=pophelp_button value="HELP!"></td>';
      m += '<td align=center>Pick City:<span id=popcity></span></td>';
      m += '<td align=center>Population Gain per cycle: <span id=poptab_cycle_pop></span></td>';
      m += '<td align=center> Troops to dismiss: <select id=poptab_troop_dismiss>';
       m+='  <option value ="1">'+unsafeWindow.unitcost['unt1'][0]+'</option>';
       m+='  <option value ="2">'+unsafeWindow.unitcost['unt2'][0]+'</option>';
       m+='  <option value ="3">'+unsafeWindow.unitcost['unt3'][0]+'</option>';
       m+='  <option value ="4">'+unsafeWindow.unitcost['unt4'][0]+'</option>';
       m+='  <option value ="5">'+unsafeWindow.unitcost['unt5'][0]+'</option>';
       m+='  <option value ="6">'+unsafeWindow.unitcost['unt6'][0]+'</option>';
       m+='  <option value ="7">'+unsafeWindow.unitcost['unt7'][0]+'</option>';
       m+='  <option value ="8">'+unsafeWindow.unitcost['unt8'][0]+'</option>';
       m+='  <option value ="9">'+unsafeWindow.unitcost['unt9'][0]+'</option>';
       m+='  <option value ="10">'+unsafeWindow.unitcost['unt10'][0]+'</option>';
       m+='  <option value ="11">'+unsafeWindow.unitcost['unt11'][0]+'</option>';
       m+='  <option value ="12">'+unsafeWindow.unitcost['unt12'][0]+'</option></select>';
      m += '</tr>';
      m += '</table>';
      
      m += '<DIV class=pbStat>City Requirements:</div>';
      m += '<table border="0" width="100%">';      
      m += '<tr>';
      m += '<td>Current Food: &nbsp<span id=poptab_cur_food></span></td>';
      m += '<td>Current Wood: &nbsp<span id=poptab_cur_wood></span></td>';
      m += '<td>Current Ore: &nbsp&nbsp<span id=poptab_cur_ore></span></td>';
      m += '<td>Current dismissable troops: <span id=poptab_cur_mm></span></td>';
      m += '</tr>';
      m += '<tr>';
      m += '<td>Needed Food: &nbsp<span id=poptab_needed_food></span></td>';
      m += '<td>Needed Wood: &nbsp<span id=poptab_needed_wood></span></td>';
      m += '<td>Needed Ore: &nbsp&nbsp<span id=poptab_needed_ore></span></td>';
      m += '<td>Needed dismissable troops: <span id=poptab_needed_mm></span></td>';
      m += '</tr>';
      m += '</table>';

      m += '<DIV class=pbStat>City Status:</div>';
      m += '<table border="0" width="100%">';   
      m += '<tr align=center>';
      m += '<td>Maximum Idle Population: <span id=poptab_max_idle_pop></span></td>';
      m += '<td># Slots Used: <span id=poptab_slots_used></span><br></td>';
      m += '<td># of barracks: <span id=poptab_barracks></span></td>';
      //m += '<td> </td>';
      m += '</tr>';
      m += '<tr align=center>';
      m += '<td>Current Idle Population: <span id=poptab_cur_idle_pop></span></td>';
      m += '<td># Slots Free: <span id=poptab_slots_free></span></td>';
      m += '<td># of cottages: <span id=poptab_cottages></span></td>';
      //m += '<td> </td>';
      m += '</tr>';     
      m += '</table>';

      m += '<DIV class=pbStat>Commands:</div>';
      m += '<table border="0" width="100%">';   
      m += '<tr align=center>';
      m += '<td><input type="submit" id="poptab_dismiss_mm" value="Dismiss troops" disabled></td>';
      m += '<td><input type="submit" id="poptab_queue_st" value="Queue Supply Troops" disabled></td>';
      m += '<td><input type="submit" id="poptab_del_queues" value="Delete All Queues" disabled></td>';
      m += '<td><input type="submit" id="poptab_run_cycle" value="Run cycle" disabled></td>';
      //m += '<td><input type="submit" id="poptab_test" value="Test"></td>';
      m += '</tr>';     
      m += '</table>';
   
      m += '<DIV class=pbStat>Action Log:</div>';

      m += '<DIV style="height:250px; max-height:250px; overflow-y:auto">';
      m += '<TABLE cellpadding=0 cellspacing=0 id=poptab_log class=pbTabLined>';
      m += '<TR><TD></td><TD width=95%></td>';
      m += '</table></div>';

      t.myDiv.innerHTML = m;

      t.logtable = document.getElementById('poptab_log');  
      var a = JSON2.parse(GM_getValue ('poptab_log_'+getServerId(), '[]'));
      if (matTypeof(a) == 'array')
         {
         t.loglast99 = a;
         for (var i=0; i<t.loglast99.length; i++)     t.addlogrow (t.loglast99[i].msg, t.loglast99[i].ts);
         }
      window.addEventListener('unload', t.onUnload, false);

      t.tcp = new CdispCityPicker ('popcityselect', document.getElementById('popcity'), true, null, selbut);
      
      document.getElementById('pophelp_button').addEventListener     ('click', function(){   t.helpPop(this);                    } , false);
      document.getElementById('popcity').addEventListener                  ('click', function(){   t.show_city (t.tcp.city.id);  } , false);
      document.getElementById('poptab_dismiss_mm').addEventListener  ('click', function(){   t.dismiss_mm(t.tcp.city.id);  } , false);
      document.getElementById('poptab_queue_st').addEventListener    ('click', function(){   t.queue_st  (t.tcp.city.id);  } , false);
      document.getElementById('poptab_del_queues').addEventListener  ('click', function(){   t.del_queues_start(t.tcp.city.id);  } , false);
      document.getElementById('poptab_run_cycle').addEventListener   ('click', function(){   t.run_cycle (t.tcp.city.id);  } , false);
      //document.getElementById('poptab_test').addEventListener   ('click', function(){   t.btest  ();   } , false);
         document.getElementById('poptab_troop_dismiss').addEventListener('change', function(){t.poptab_troop_dismiss = document.getElementById('poptab_troop_dismiss').value;} , false);
  
   },

   disable_btns : function ()
      {
      var t = Tabs.popcontrol;
      t.busy = true;
      document.getElementById('poptab_del_queues'  ).disabled = true;
      document.getElementById('poptab_queue_st').disabled = true;
      document.getElementById('poptab_dismiss_mm').disabled = true;
      document.getElementById('poptab_run_cycle').disabled = true; 
      },

   onUnload : function ()
      {
      var t = Tabs.popcontrol;
      //if (!ResetAll) GM_setValue ('log_'+getServerId(), JSON2.stringify(t.last50));
      GM_setValue ('poptab_log_'+getServerId(), JSON2.stringify(t.loglast99));
      },
    
   addlogrow : function (msg, ts)
      {
      var t = Tabs.popcontrol;
      if (t.logtable.rows.length >= t.maxEntries)  t.logtable.deleteRow(t.maxEntries-1);
      var row = t.logtable.insertRow(0);
      row.vAlign = 'top';
      row.insertCell(0).innerHTML = ts;
      row.insertCell(1).innerHTML = msg;
      },
  
   log : function (msg)
      {
      var t = Tabs.popcontrol;
      var ts = new Date().toTimeString().substring (0,8);
      for (postcity in Seed.cities) if (Seed.cities[postcity][0] == t.tcp.city.id) logcity = Seed.cities[postcity][1];
      msg = logcity + ": " + msg;
      t.addlogrow (msg, ts);
      while (t.loglast99.length >= 99)
      t.loglast99.shift();
      t.loglast99.push ({msg:msg, ts:ts});
      },

  hide : function (){         // called whenever the main window is hidden, or another tab is selected
    var t = Tabs.popcontrol;
    clearTimeout (t.timer);
  },
  
  show : function (){         // called whenever this tab is shown
    var t = Tabs.popcontrol;
    clearTimeout (t.timer);
    t.timer = setTimeout (t.show, 2000);
      t.show_city(t.tcp.city.id);
  },

   helpPop : function ()
      {
      var helpText = "";
      
      helpText += '<p>** This is a work in progress... If it gets stuck, refresh. By ADABman / Lurkin **';
      helpText += 'Probably a good idea to temporarily turn off auto transport, auto reassign, and auto train, when using this.';
      
      helpText += '<p>POPULATION CONTROL tab will help you convert your excess/useless millitiamen ';
      helpText += 'into massive amounts of idle population. Massive idle population is very useful ';
      helpText += 'to have before a might tournament starts, or if you want to do a massive siege ';
      helpText += 'build with a Merlins tutelage.';
      helpText += '</p>';
      
      helpText += '<p>The CITY REQUIREMENTS area displays the amount of resouces and Militiamen ';
      helpText += 'required for a \'full cycle\' of building massive idle population. If any of these ';
      helpText += 'requirements are not met, they will be displayed in red.';
      helpText += '</p>';
      
      helpText += '<p>The CITY STATUS area displays the maximum amount of population your cottages ';
      helpText += 'provide, and the current amount of idle population in your city. This area also ';
      helpText += 'shows the number of training queue slots total and in use.';
      helpText += '</p>';
      
      helpText += '<p>The COMMANDS area displays the buttons that automate this process:';
      helpText += '</p>';

      helpText += '<UL>';
      
      helpText += 'DISMISS MM BUTTON<BR><li>' + dismissBtn_help1 + '</li>';
      helpText += '<li>' + dismissBtn_help2 + '</li><BR>';
      
      helpText += 'QUEUE SUPPLY TROOP BUTTON<BR><li>' + queueBtn_help1 + '</li>';
      helpText += '<li>' + queueBtn_help2 + '</li><BR>';
      
      helpText += 'DELETE QUEUE BUTTON<BR><li>' + deleteBtn_help1 + '</li>';
      helpText += '<li>' + deleteBtn_help2 + '</li>';
      helpText += '<li>' + deleteBtn_help3 + '</li><BR>';
      
      helpText += 'RUN CYCLE BUTTON<BR><li>' + runcycleBtn_help1 + '</li>';
      helpText += '<li>' + runcycleBtn_help2 + '</li>';
      helpText += '<li>' + runcycleBtn_help3 + '</li><BR>';
   
      helpText += '</UL><BR>';
      
      //function CPopup (prefix, x, y, width, height, enableDrag, onClose)
      var pop = new pbPopup ('popcontrol_Help', 0, 0, 740, 600, true);
      pop.centerMe (mainPop.getMainDiv());  
      pop.getMainDiv().innerHTML = helpText;
      pop.getTopDiv().innerHTML = '<CENTER><B>Power Bot Help</b>:  Population Control</center>';
      pop.show (true);
      },

   show_city : function (cityId)
      {
      var t = Tabs.popcontrol;

      t.st_food = 50;
      t.st_wood = 150;
      //t.st_stone = 0;
      t.st_ore = 10;
      
      var green = '#03F003';
      var red =   '#F0303';

      t.max_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[1])).toFixed(0);
      t.cur_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[0])).toFixed(0);
      document.getElementById('poptab_max_idle_pop').innerHTML = t.max_idle_pop;
      document.getElementById('poptab_cur_idle_pop').innerHTML = t.cur_idle_pop;

      t.barracks = parseInt(getCityBuilding(cityId, 13).count);
      t.cottages = parseInt(getCityBuilding(cityId, 5).count);
      t.slots_used = parseInt(Seed.queue_unt['city'+cityId].length);
      t.slots_free = parseInt(t.barracks - t.slots_used);
      document.getElementById('poptab_barracks').innerHTML = t.barracks;
      document.getElementById('poptab_cottages').innerHTML = t.cottages;
      document.getElementById('poptab_slots_used').innerHTML = t.slots_used;
      document.getElementById('poptab_slots_free').innerHTML = t.slots_free;

      t.cycle_pop = (parseInt(t.barracks) * parseInt(t.max_idle_pop)) + (parseInt(t.max_idle_pop) * 2);
      document.getElementById('poptab_cycle_pop').innerHTML = addCommas( t.cycle_pop / 2 );

      t.cur_food = parseInt(Seed.resources['city'+cityId].rec1[0]/3600);
      t.cur_wood = parseInt(Seed.resources['city'+cityId].rec2[0]/3600);
      //t.cur_stone = parseInt(Seed.resources['city'+cityId].rec3[0]/3600);
      t.cur_ore = parseInt(Seed.resources['city'+cityId].rec4[0]/3600);
      
      document.getElementById('poptab_cur_food').innerHTML = addCommas (t.cur_food);
      document.getElementById('poptab_cur_wood').innerHTML = addCommas (t.cur_wood);
      //document.getElementById('poptab_cur_stone').innerHTML = addCommas (t.cur_stone);
      document.getElementById('poptab_cur_ore').innerHTML = addCommas (t.cur_ore);
      
      t.needed_food = parseInt(t.cycle_pop) * parseInt(t.st_food);
      t.needed_wood = parseInt(t.cycle_pop) * parseInt(t.st_wood);
      //t.needed_stone = 0;//parseInt(t.cycle_pop) * parseInt(t.st_Stone);
      t.needed_ore = parseInt(t.cycle_pop) * parseInt(t.st_ore);
      
      document.getElementById('poptab_needed_food').innerHTML = addCommas (t.needed_food);
      document.getElementById('poptab_needed_wood').innerHTML = addCommas (t.needed_wood);
      //document.getElementById('poptab_needed_stone').innerHTML = addCommas (t.needed_stone);
      document.getElementById('poptab_needed_ore').innerHTML = addCommas (t.needed_ore);
      
      document.getElementById('poptab_needed_food').style.color = (t.needed_food  > t.cur_food?'red':'green');
      document.getElementById('poptab_cur_food').style.color = (t.needed_food  > t.cur_food?'red':'green');
      document.getElementById('poptab_needed_wood').style.color  = (t.needed_wood  > t.cur_wood?'red':'green');
      document.getElementById('poptab_cur_wood').style.color = (t.needed_wood  > t.cur_wood?'red':'green');
      //document.getElementById('poptab_needed_stone').style.color = (t.needed_stone > t.cur_stone?'red':'green');
      //document.getElementById('poptab_cur_stone').style.color = (t.needed_stone > t.cur_stone?'red':'green');
      document.getElementById('poptab_needed_ore').style.color = (t.needed_ore  > t.cur_ore?'red':'green');
      document.getElementById('poptab_cur_ore').style.color = (t.needed_ore  > t.cur_ore?'red':'green');

      t.needed_mm = t.cycle_pop;
      t.cur_mm = parseInt(Seed.units['city'+cityId]['unt' + t.poptab_troop_dismiss]);
      document.getElementById('poptab_needed_mm').innerHTML = addCommas(t.needed_mm);
      document.getElementById('poptab_cur_mm').innerHTML = addCommas(t.cur_mm);
      
      document.getElementById('poptab_needed_mm').style.color = (t.needed_mm  > t.cur_mm?'red':'green')
      document.getElementById('poptab_cur_mm').style.color = (t.needed_mm  > t.cur_mm?'red':'green')
      
      dismissBtn_help1 = "This button is used to quickly get your city to its maximum idle population allowed by dismissing just the right amount of militiamen.";
      dismissBtn_help2 = "This button will only light up when when your city is not at its maximum population, and then only if you have enough MM in your city to dismiss.";
      need_to_dismiss = parseInt(t.max_idle_pop - t.cur_idle_pop);
      dismissBtn = document.getElementById('poptab_dismiss_mm');
      if(parseInt(need_to_dismiss) > 0 && parseInt(need_to_dismiss) <= parseInt(t.cur_mm) && !t.busy && !t.cycle_running)
         {
         dismissBtn.disabled = false;
         dismissBtn.value = "Dismiss " + addCommas(need_to_dismiss) + " Troops";
         }
      else
         {
         dismissBtn.disabled = true;
         dismissBtn.value = "Dismiss Troops";
         }

      queueBtn_help1 = "This button is used to train all the idle population into Supply Troops.";
      queueBtn_help2 = "This button will only light up when your city is at full idle population, and then only if you have enough resources to train all those Supply Troops and at least 1 free training slot.";
      unitId = 1; 
      var res_ok = 0;
      for (var i = 1; i < 5; i++)
         {
         var res_need = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(t.cur_idle_pop);
         var res_have = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]);
         if(parseInt(res_need) > parseInt(res_have))  {  res_ok++;   }
         }
      queueBtn = document.getElementById('poptab_queue_st');
      if(parseInt(t.slots_free) > 0 && parseInt(t.cur_idle_pop) >= parseInt(t.max_idle_pop) && parseInt(res_ok)==0 && !t.busy && !t.cycle_running)
         {
         queueBtn.disabled = false;
         queueBtn.value = "Queue " + addCommas(t.cur_idle_pop) + " Supply Troops";
         }
      else
         {
         queueBtn.disabled = true;
         queueBtn.value = "Queue Supply Troops";
         }

      deleteBtn_help1 = "This button is used to quickly delete all those queued up Supply Troops, returning 1/2 the used population (and resources?).";
      deleteBtn_help2 = "This button will only light up when there is at least 1 training queue slot used.";
      //deleteBtn_help3 = "** Due to a bug, you should refresh your game before using this button! **";
      deleteBtn_help3 = "If you have any problems with this button, refresh and try again.";
      deletebtn = document.getElementById('poptab_del_queues'  );
      if(Seed.queue_unt['city'+cityId].length > 0 && !t.busy && !t.cycle_running)
         {
         deletebtn.disabled = false;
         deletebtn.value = " Delete " + Seed.queue_unt['city'+cityId].length + " Queues";
         }
      else
         {
         deletebtn.disabled = true;
         deletebtn.value = "Delete All Queues";
         }

      runcycleBtn_help1 = "This button is used to automate the entire process of repeatedly dismissing Militiamen then queueing Supply Troops, and then finally delete all of those queues.";
      runcycleBtn_help2 = "This button will only light up when your city has the required amount of resources and Militiamen";
      //runcycleBtn_help3 = "------ This button is disabled for now. -----";
      runcycleBtn_help3 = "If the queue slots wont delete, refresh and hit the 'Delete All Queues' button.";
      res_ok = 0;
      t.cycle_pop_continue = (parseInt(t.slots_free) * parseInt(t.max_idle_pop)) + (parseInt(t.max_idle_pop) * 2);
      for (var i = 1; i < 5; i++)
         {
         var res_need = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(t.cycle_pop_continue);
         var res_have = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]);
         if(parseInt(res_need) > parseInt(res_have))  {  res_ok++;   }
         }
      runcycleBtn = document.getElementById('poptab_run_cycle');
      //if(parseInt(t.cur_idle_pop) >= parseInt(t.max_idle_pop) && parseInt(res_ok)==0 && !t.busy && !t.cycle_running)
      t.needed_mm_continue = t.cycle_pop_continue;
      if(parseInt(t.needed_mm) <= parseInt(t.cur_mm) && parseInt(res_ok)==0 && !t.busy && !t.cycle_running)
         {
         runcycleBtn.disabled = false;
         }
      else
         {
         runcycleBtn.disabled = true; 
         }
      
      },

   run_cycle : function (cityId)
      {
      // Temp disable auto train for this city & auto reassign & auto transport & auto refresh
      // log all that
      
      var t = Tabs.popcontrol;
      clearTimeout (t.timer);
      clearTimeout (t.timer_cycle);
      t.disable_btns();
      if(!t.cycle_running)
         {
         t.log("Starting population build cycle. Population at start: " + t.cur_idle_pop);
         t.cycle_running = true;
         t.cycle_step = 1;
         }
      
      //t.actionlog("1");
//      t.max_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[1])).toFixed(0);
      t.cur_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[0])).toFixed(0);
      //num = parseInt(t.max_idle_pop) - parseInt(t.cur_idle_pop);
      if(parseInt(t.cur_idle_pop) < parseInt(t.max_idle_pop))  // Need to Dismiss MM
         {
         if (t.cycle_running && t.last_ran == 'train') {
            t.dismiss_mm(cityId);
            t.last_ran = 'dismiss';
         } else {
            t.timer_cycle = setTimeout (function() {t.run_cycle(cityId)}, 1500);
         }
            
         
         //t.actionlog("2");
         }
      else if(parseInt(t.slots_free) > 0 && parseInt(t.cur_idle_pop) >= parseInt(t.max_idle_pop)) // Need to queue supply troops
         {
         if (t.cycle_running) {
            t.queue_st(cityId);
            t.last_ran = 'train';
         }
         //t.actionlog("3");
         }
      else if(parseInt(t.slots_free) == 0)   // Delete all the queues
         {
         //t.actionlog("4");
         t.cycle_running = false;
         setTimeout(unsafeWindow.update_seed_ajax, 250);
         t.del_queues_start(t.tcp.city.id);
         t.timer = setTimeout (t.show, 1000);
         return;
         }
      else
         {
         t.log("Waiting..."); // Wait
         }
      //t.actionlog("5");
      setTimeout(unsafeWindow.update_seed_ajax, 250);
      t.timer_cycle = setTimeout (function() {t.run_cycle(cityId)}, 1500);
      },

   dismiss_mm : function (cityId)
      {
      var t = Tabs.popcontrol;
      t.disable_btns();
      
      unitId = t.poptab_troop_dismiss;

    //  t.max_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[1])).toFixed(0);
      t.cur_idle_pop = (parseInt(Seed.citystats['city'+cityId].pop[0])).toFixed(0);
      num = parseInt(t.max_idle_pop) - parseInt(t.cur_idle_pop);
      //t.log(num);
      
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.cid = cityId;
      params.type = unitId;
      params.quant = num;

      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/dismissUnits.php" + unsafeWindow.g_ajaxsuffix,
         {
         method: "post",
         parameters: params,
         onSuccess: function(rslt)
            {
            if (rslt.ok) 
               {
               //t.log("Dismissed "+ addCommas(num) +" "+ troops[unitId]);
               t.log("Dismissed "+ addCommas(num) +" Troops");
               Seed.units['city'+cityId]['unt'+unitId] -= num;
               if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
               //setTimeout(unsafeWindow.update_seed_ajax, 250);
               t.busy = false;
               t.show_city(cityId);
               
               }
            else
               {
               //t.log("FAILED to dismiss "+ addCommas(num) +" "+ troops[unitId] + " :(");
               t.log("FAILED to dismiss "+ addCommas(num) +" Militiamen :(");
               t.busy = false;
               }
            },
         });      
      setTimeout(unsafeWindow.update_seed_ajax, 250);
      },

   queue_st : function (cityId)
      {
      var t = Tabs.popcontrol;
      t.disable_btns();

      unitId = 1;
      num = t.cur_idle_pop;
      //num = 15;
      
      var time = unsafeWindow.modal_barracks_traintime(unitId, num);
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.cid = cityId;
      params.type = unitId;
      params.quant = num;
      params.gambleId = 0;

      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix,
         {
         method: "post",
         parameters: params,
         onSuccess: function(rslt)
            {
            if (rslt.ok) 
               {
               //t.log("Trained "+ addCommas(num) +" "+ troops[unitId]);
               t.log("Trained "+ addCommas(num) +" Supply Troops");
               if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
               for (var i = 1; i < 5; i++)
                  {
                  var resourceLost = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(num);
                  if(rslt.gamble) resourceLost = resourceLost*rslt.gamble[i];
                  unsafeWindow.seed.resources["city" + cityId]["rec" + i][0] = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]) - resourceLost;
                  }
               unsafeWindow.seed.citystats["city" + cityId].gold[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].gold[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][5]) * parseInt(num);
               unsafeWindow.seed.citystats["city" + cityId].pop[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].pop[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][6]) * parseInt(num);
               //unsafeWindow.seed.queue_unt["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, null]);
               unsafeWindow.seed.queue_unt["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, rslt.ticksNeeded, null]);
               t.busy = false;
               t.show_city(cityId);
               }
            else
               {
               //t.log("FAILED to train "+ addCommas(num) +" "+ troops[unitId] + " :(");
               t.log("FAILED to train "+ addCommas(num) +" Supply Troops :(");
               t.busy = false;
               }
            },
         });
      setTimeout(unsafeWindow.update_seed_ajax, 250);
      },


   del_queues_start : function (cityId)
      {
      var t = Tabs.popcontrol;
      t.disable_btns();

      t.del_count = Seed.queue_unt['city'+cityId].length;
      t.log("Attempting to delete " + t.del_count + " Queue slots...");
      t.del_queues(cityId);
      },

   del_queues : function (cityId)
      {
      var t = Tabs.popcontrol;
      clearTimeout (t.timer_del);

      var q = Seed.queue_unt['city'+cityId];
      var qs = q.toString();

     // if(q.length > 0 || t.del_count > 0)   mac mod need to change to only delete ques =to max pop
       //  {
       //  t.del_count -= 1;
      //   typetrn =      q[0][0];
      //   numtrptrn = q[0][1];
      //   trnTmp =    q[0][2];
      //   trnETA =       q[0][3];
      //   trnNeeded = q[0][5];
      //   trainingId = 0;

       //  t.delete_queue_slot(typetrn, numtrptrn, trnTmp, trnETA, trnNeeded, cityId, trainingId)
       //  t.delete_queue_slot(typetrn, numtrptrn, trnTmp, parseInt(trnETA)-1, trnNeeded, cityId, trainingId) //?!
       //           }
     // else
      //   {
         t.log("No more queue slots to delete.");
         t.del_count = 0;
         t.busy = false;
         return;
       //  }
      setTimeout(unsafeWindow.update_seed_ajax, 250);
      t.timer_del = setTimeout (function() {t.del_queues(cityId)}, 1500);
      },

   delete_queue_slot : function (typetrn, numtrptrn, trnTmp, trnETA, trnNeeded, cityId, trainingId)
      {
      var t = Tabs.popcontrol;
      var uW = unsafeWindow;
      var params = uW.Object.clone(uW.g_ajaxparams);
      params.pf =0;
      params.requestType = "CANCEL_TRAINING";
      params.cityId = cityId;
      params.typetrn = typetrn;
      params.numtrptrn = numtrptrn;
      params.trnETA = trnETA;
      params.trnTmp = trnTmp;
      params.trnNeeded = trnNeeded;

      new AjaxRequest(uW.g_ajaxpath + "ajax/cancelTraining.php" + uW.g_ajaxsuffix,
         {
         method: "post",
         parameters: params,
         onSuccess: function (message)
            {
            var rslt=eval("("+message.responseText+")");
            if (rslt.ok)
               {
               t.log("Deleted queue of "+ addCommas(numtrptrn) +" "+ troops[typetrn]);
               if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
               var k=0;
               for(var j=0;j<Seed.queue_unt["city"+cityId].length;j++)
                  {
                  if(j>trainingId)
                     {
                     Seed.queue_unt["city"+cityId][j][2]=parseInt(rslt.dateTraining[k]["start"]);
                     Seed.queue_unt["city"+cityId][j][3]=parseInt(rslt.dateTraining[k]["end"]);
                     k++;
                     }
                  }
               Seed.queue_unt["city"+cityId].splice(trainingId,1);
               for(var i=1;i<5;i++)
                  {
                  var totalReturn=parseInt(uW.unitcost["unt"+typetrn][i])*parseInt(numtrptrn)*3600/2;
                  Seed.resources["city"+cityId]["rec"+i][0]=parseInt(Seed.resources["city"+cityId]["rec"+i][0])+totalReturn;
                  }
               }
            else
               {
               }
            },
         onFailure: function ()
            {
            },
         });
      },


}

/***** Ascension Tab ******/
Tabs.ascension = {
    tabLabel: 'Ascension',
    tabOrder: 300,
    myDiv: null,

    init: function (div) {
        var t = Tabs.ascension;
        t.myDiv = div;
        var m = '<DIV id=pbAscensionMain></div><TABLE id=pbAscension><TR>';
        m += '<TD></td><TD>Percent</td><TD><CENTER>Menu</center></td><TD>Current Level</td><TD>Current Cost</td><TD>'+strButton20(translate('Building Values'), 'id=pbBuildingValues') +'</td><TR>';
        for (i = 0; i < Cities.cities.length; i++) {
            var cityPrestige = Seed.cityData.city[Cities.cities[i].id].cityValue;
            var cityPrestigeLevel = Seed.cityData.city[Cities.cities[i].id].prestigeInfo.prestigeLevel;
            var isPrestigeCity = Seed.cityData.city[Cities.cities[i].id].isPrestigeCity;
            var currentGemPrice = null;
            var fullPrestige = 1200;
            var progressWidth = parseInt(((cityPrestige / fullPrestige) * 100));
            if (progressWidth > 100) progressWidth = 100;
            var fullBarWidth = 378;
            var gemFullPrice = 1250;
            m += '<TR><TD>City ' + Cities.cities[i].name + ' - </td>';
            m += '<TR><TD background="https://koc-power-bot.googlecode.com/svn/trunk/progress_brown_bar.png" width=' + fullBarWidth + ' height=25">';
            m += '<DIV id=pbGreenBar_' + i + '></div></td><TD align=center><DIV id=pbProgPerc_' + i + '></div></td><TD><INPUT id=pbAscendBtn_' + Cities.cities[i].id + ' type=submit class=pbButton value="Ascend"></td><TD align=center><DIV id=pbCityPrestigeLevel_' + i + '></div></td><TD align=center><DIV id=pbGemCost_' + Cities.cities[i].id + '></div></td><TD align=center><CENTER><DIV id=pbAscCurMight_'+i+'></div></center></td>';
        }
        div.innerHTML = m;
        document.getElementById('pbBuildingValues').addEventListener('click', function(){t.paintHelp();});
    },
    paintHelp: function() {
    	var t = Tabs.ascension;
    	var helpText = translate("Ascension Building Values");
       	helpText += '<TABLE><TR><TD align=center>Building</td><TD align=center width=50>Lvl 1</td><TD align=center width=50>+1 Lvl</td></tr>';

       	helpText += '<TR><TD>Castle</td><TD><CENTER>10</center></td><TD><CENTER>+8</center></td></tr>';       	
       	helpText += '<TR><TD>Tavern</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>Knights Hall</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>Alchemy Lab</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>Rally Point</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>Wall</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>DRUID Barracks (field)</td><TD><CENTER>7</center></td><TD><CENTER>+6</center></td></tr>';
       	helpText += '<TR><TD>DRUID Apothecary (field)</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>Embassy</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>Market</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>Watch Tower</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>Spire</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>Apothecary</td><TD><CENTER>6</center></td><TD><CENTER>+5</center></td></tr>';
       	helpText += '<TR><TD>NORMAL Barracks</td><TD><CENTER>2</center></td><TD><CENTER>+2</center></td></tr>';
       	helpText += '<TR><TD>Cottage</td><TD><CENTER>2</center></td><TD><CENTER>+2</center></td></tr>';
       	helpText += '</table><TABLE>';
       	helpText += '<TR><TR><TD>These numbers are for every added level of a building. Whether you are building it to level 2 or level 10, it will only add this amount to the total, shown under this help button. Every buildings "might" value combines to give the total. Once it reaches 1200, you are at 100% and can level up again.</td></tr></tr>';
       	helpText += '</table>';

       	var pop = new pbPopup ('ascensionHelp', 0, 0, 400, 400, true);
       	pop.centerMe (mainPop.getMainDiv());  
       	pop.getMainDiv().innerHTML = helpText;
       	pop.getTopDiv().innerHTML = '<CENTER><B>AIO Script '+translate("Help")+': '+translate("Ascension")+'</b></center>';
       	pop.show (true);
    },
    paintTab: function () {
        for (i = 0; i < Cities.cities.length; i++) {
            var cityPrestige = Seed.cityData.city[Cities.cities[i].id].cityValue;
            var cityPrestigeLevel = Seed.cityData.city[Cities.cities[i].id].prestigeInfo.prestigeLevel;
            var isPrestigeCity = Seed.cityData.city[Cities.cities[i].id].isPrestigeCity;
            var currentGemPrice = null;
            var fullPrestige = 1200;
            var progressWidth = parseInt(((cityPrestige / fullPrestige) * 100));
            if (progressWidth > 100) progressWidth = 100;
            var fullBarWidth = 378;
            var gemFullPrice = 1250;
            m += '<TR><TD>City ' + Cities.cities[i].name + ' - </td>';
            m += '<TR><TD style="background:https://koc-power-bot.googlecode.com/svn/trunk/progress_brown_bar.png" width=100% height=25">';
            if (isPrestigeCity) {
                if (cityPrestigeLevel < 3) {
                    document.getElementById('pbGreenBar_' + i).innerHTML = '<img src="https://koc-power-bot.googlecode.com/svn/trunk/progress_green_bar.png" width=' + progressWidth + '% height=25>'
                    document.getElementById('pbProgPerc_' + i).innerHTML = progressWidth + '%';
                    document.getElementById('pbCityPrestigeLevel_' + i).innerHTML = cityPrestigeLevel + '/3';
                    document.getElementById('pbAscCurMight_'+i).innerHTML = cityPrestige + '/1200';
                } else {
                    document.getElementById('pbGreenBar_' + i).innerHTML = '<CENTER><B>C O M P L E T E &nbsp;&nbsp;&nbsp; (for now)</center>'
                    document.getElementById('pbProgPerc_' + i).innerHTML = 'N/A';
                    document.getElementById('pbCityPrestigeLevel_' + i).innerHTML = 'N/A';
                    document.getElementById('pbAscCurMight_' + i).innerHTML = 'N/A';
                }
                m += '<TR>';
            } else {
                document.getElementById('pbGreenBar_' + i).innerHTML = '<CENTER><B>C I T Y &nbsp;&nbsp;&nbsp; N O T  &nbsp;&nbsp;&nbsp; A S C E N D E D &nbsp;&nbsp;&nbsp; Y E T</center>'
                document.getElementById('pbProgPerc_' + i).innerHTML = '<CENTER>N/A</center>';
                document.getElementById('pbCityPrestigeLevel_' + i).innerHTML = '<CENTER>0/3</center>';
                document.getElementById('pbAscCurMight_' + i).innerHTML = 'N/A';
            }
        }
    },
    clickCitySelect: function (city) {
        var t = Tabs.ascension;
        t.selectedCity = city;
        t.JumpCity(city);
        unsafeWindow.cm.PrestigeManagerController.open()
    },
    JumpCity: function (city) {
        var t = Tabs.ascension;
        for (i = 0; i < Seed.cities.length; i++) {
            if (Seed.cities[i][0] == city) var cityNum = i;
        }
        cityNum++;
        var obj = document.getElementById('citysel_' + cityNum);
        return t.ClickWin(window, obj, 'click');
    },
    ClickWin: function (win, obj, evtName) {
        var evt = win.document.createEvent("MouseEvents");
        evt.initMouseEvent(evtName, true, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        return !obj.dispatchEvent(evt);
    },
    getGemCost: function (cityId, callback) {
        var t = Tabs.ascension;
        var isPrestigeCity = Seed.cityData.city[cityId].isPrestigeCity;
        var cityPrestigeLevel = Seed.cityData.city[Cities.cities[i].id].prestigeInfo.prestigeLevel;
        if (isPrestigeCity && cityPrestigeLevel < 3) {
            var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
            params.cid = cityId;
            params.prestigeType = 1;
             
            new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getPrestigeCost.php" + unsafeWindow.g_ajaxsuffix, {
                method: "post",
                parameters: params,
                onSuccess: function (rslt) {
                    if (rslt.ok) {
                        callback(cityId, rslt.cost, rslt.original_cost)
                    }
                }
            });
        } else {
            callback(cityId, null, null)
        }
    },
    show: function () {
        var t = Tabs.ascension;
        t.Timer = setInterval(t.paintTab, 1000)
        for (i = 0; i < Cities.cities.length; i++) {
            document.getElementById('pbAscendBtn_' + Cities.cities[i].id).addEventListener('click', function () {
                var t = Tabs.ascension
                var what = this.id.substr(12); // strip first 12 char's -> pbAscendBtn_
                t.clickCitySelect(what);
            });
            var isPrestigeCity = Seed.cityData.city[Cities.cities[i].id].isPrestigeCity;
            if (isPrestigeCity) {
                t.getGemCost(Cities.cities[i].id, function (cid, cost, origCost) {
                    if (cost < 0 || cost == null || origCost == null) {
                        document.getElementById('pbGemCost_' + cid).innerHTML = '<CENTER>Max</center>';
                    } else {
                        document.getElementById('pbGemCost_' + cid).innerHTML = '<CENTER>' + cost + '/' + origCost + '</center>';
                    }
                })
            } else {
                document.getElementById('pbGemCost_' + Cities.cities[i].id).innerHTML = '<CENTER>Not Ascended</center>';
            }
        }
    },
    hide: function () {
        var t = Tabs.ascension;
        clearInterval(t.Timer)
    },
}

/**************************** TurboSearch Tab ****************************************/
Tabs.TurboSearch = {
myDiv: null,
tileTypes:{0:"Bog",10:"Grassland",11:"Lake",20:"Woods",30:"Hills",40:"Mountain",50:"Plain",51:"City",52:"Ruin",53:"Misted City",54:"Dark Forest",55:"Mercenary Hideout"},
rankings:{},
provinces:{	101:{x:0,y:0},102:{x:150,y:0},103:{x:300,y:0},104:{x:450,y:0},105:{x:600,y:0},
			106:{x:0,y:150},107:{x:150,y:150},108:{x:300,y:150},109:{x:450,y:150},110:{x:600,y:150},
			111:{x:0,y:300},112:{x:150,y:300},113:{x:450,y:300},114:{x:600,y:300},
			115:{x:0,y:450},116:{x:150,y:450},117:{x:300,y:450},118:{x:450,y:450},119:{x:600,y:450},
			120:{x:0,y:600},121:{x:150,y:600},122:{x:300,y:600},123:{x:450,y:600},124:{x:600,y:600},
},

userInfo:[],
allianceNames:[],
data:[],

	init: function(div){
		var t = Tabs.TurboSearch;
		t.myDiv = div;
		unsafeWindow.pbExportToRaid = t.ExportToRaid;
		unsafeWindow.GoToAttackTab = GoToAttackTab;

		var m = '<DIV class=pbStat>Turbo Search</div>';
		m+= '<BR><B>Search from: </b><SPAN id=TScityPick></span>&nbsp&nbsp&nbspX:&nbsp<INPUT id=TSfromX maxlength=3 type=text>&nbsp&nbsp&nbspY:&nbsp<INPUT id=TSfromY maxlength=3 type=text>';
		m+= '&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSearch:&nbsp<select id=TSselectRadius>';
		for (var i=5;i<=45;i+=5) m+='<option value='+i+'>'+i+' Blocks</option>';
		m+='<option value='+null+'>--------------</option>';
		for (var i=1;i<=24;i++) m+='<option value='+(100+i)+'>'+unsafeWindow.provincenames['p'+i]+'</option>';
		m+= '</select>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<INPUT id=TSsearchButton type=submit class=pbButton value="Start Search">';
		m+= '<BR><BR><DIV class=pbStat><TABLE class=pbTab width=350px align=center><TR><TD>Search Results</td><TD><INPUT id=TSscoutButton type=submit class=pbButton value="Scout"></td><TD><INPUT id=TSShowMisted type=submit class=pbButton value="Show misted"></td></tr></table></div>';
		m+= '<TABLE id=TSleftMain width=100% class=pbTab><TD style="vertical-align:top;"><DIV style="width:150px;max-width:150px;overflow:auto;" id=TSleft></div></td><TD style="text-align:left;vertical-align:top;"><DIV style="max-width:700px;height:450px;max-height:450px;overflow:auto"id=TSright></div></td></table>';

		t.myDiv.innerHTML = m;
		
		t.from = new CdispCityPicker ('pbSearchPicker', document.getElementById ('TScityPick'), true, t.citySelNotify,0);
		t.from.bindToXYboxes(document.getElementById ('TSfromX'), document.getElementById ('TSfromY'));
		document.getElementById('TSselectRadius').value = 10;
		document.getElementById('TSsearchButton').addEventListener ('click', function (){
			var Radius = document.getElementById('TSselectRadius').value;
			if (Radius=="null") return;
			if (document.getElementById('TSfromX').value==""  && document.getElementById('TSfromY').value== "") {alert("Please select a city or enter coords.");return;}
			document.getElementById('TSsearchButton').disabled = true;
			document.getElementById('TSsearchButton').value = "Searching";
      		if (Radius<100){
      			var blocks = MakeBlocks(parseInt(document.getElementById('TSfromX').value), parseInt(document.getElementById('TSfromY').value), parseInt(document.getElementById('TSselectRadius').value));
      			t.doSearch(blocks, parseInt(document.getElementById('TSfromX').value), parseInt(document.getElementById('TSfromY').value),blocks.length,1);
      		} 
      		if (Radius>100) {
      			var ProvinceBlocks={1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[],11:[],12:[],13:[],14:[],15:[],16:[],17:[],18:[],19:[],20:[],21:[],22:[],23:[],24:[],25:[]};
      			for (var i=1;i<=25;i++) {
      				if (i>=1 && i<=5) {var x=t.provinces[Radius].x+((i-1)*30);var y=t.provinces[Radius].y;}
      				if (i>=6 && i<=10) {var x=t.provinces[Radius].x+((i-6)*30);var y=t.provinces[Radius].y+30;}
      				if (i>=11 && i<=15) {var x=t.provinces[Radius].x+((i-11)*30);var y=t.provinces[Radius].y+60;}
      				if (i>=16 && i<=20) {var x=t.provinces[Radius].x+((i-16)*30);var y=t.provinces[Radius].y+90;}
      				if (i>=21 && i<=25) {var x=t.provinces[Radius].x+((i-21)*30);var y=t.provinces[Radius].y+120;}
      				ProvinceBlocks[i]=(MakeProvinceBlocks(x,y));
      			}
      			t.data = new Array(); 
      			t.userInfo = {};
      			t.allianceNames = {};	
      			t.ProvinceSearch(ProvinceBlocks, parseInt(document.getElementById('TSfromX').value), parseInt(document.getElementById('TSfromY').value), 1);	
      		}
      	}, false);
      	document.getElementById('TSscoutButton').addEventListener ('click', function (){
      		var list =[];
      		var element_class = document.getElementsByClassName('TSscout');
    		for (k=0;k<element_class.length;k++) if (element_class[k].checked) list.push(element_class[k].id);
    		t.doAddScout(list);
      	}, false);
      	document.getElementById('TSShowMisted').addEventListener ('click', function (){
      		var TodoList = new Array();
			for (var z=0;z<t.data.length;z++) if (t.data[z].mapDat.cityName=="???") TodoList.push({x:t.data[z].mapDat.xCoord,y:t.data[z].mapDat.yCoord});
			t.CheckMistedCities(TodoList);
      	}, false);

	},

	CheckCityMarches:function(cityID){
		var Counter=0;
		if (Seed.queue_atkp['city'+ cityID] != undefined) {
			for (atkp in Seed.queue_atkp['city'+ cityID]) if (Seed.queue_atkp['city'+ cityID][atkp]["marchUnixTime"]) Counter++;
		} else Counter=0;
		return Counter;
	},

	CheckMistedCities:function(list){
		var t = Tabs.TurboSearch;
		document.getElementById('TSright').innerHTML = "";
		var m='This function was made because Kabam needs to fix this bug, it has been around for ages.<BR>';
		m+='If you (just like me) don\'t like this exploit, please report it at: <a href="//kabam.secure.force.com/PKB/pkb_contactUs?game=All&lang=en_US&l=en_US" target="_blank">This link</a><BR><BR>';
		m+="<TABLE width=450px class=pbTab><TR><TD><B>Coord</b></td><TD><B>Player Name</b></td><TD><B>City Name</b></td></tr>";
		for (var i=0;i<list.length;i++)m+='<TR><TD>'+coordLink(list[i].x,list[i].y)+'</td><TD><DIV id="TSmistPlayer_'+list[i].x+'_'+list[i].y+'"></div></td><TD><SPAN id="TSmistCity_'+list[i].x+'_'+list[i].y+'"></span></td></tr>';
		m+='</table>'
		document.getElementById('TSright').innerHTML = m;
		t.FetchTileID(0,list.length,list)
	},

	FetchTileID:function(number,total,list){
		var t = Tabs.TurboSearch;
		if (number==total) return;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.blocks = "bl_" + list[number].x + "_bt_" + list[number].y;
    	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			for (var i in rslt.data) if(parseInt(rslt.data[i].xCoord)==list[number].x && parseInt(rslt.data[i].yCoord)==list[number].y) var tileId=parseInt(rslt.data[i].tileId)
        			t.SetBookmark(number,total,list,tileId);
        		}
      		},
    	});
	},

	SetBookmark:function(number,total,list,tileId){
		var t = Tabs.TurboSearch;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="BOOKMARK_LOCATION";
		params.tileId=tileId;
    	params.bookmarkName = "Misted_City";
    	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) t.GetBookmarkInfo(number,total,list);	
      		},
    	});
	},

	GetBookmarkInfo:function(number,total,list){
		var t = Tabs.TurboSearch;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="GET_BOOKMARK_INFO";
    	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			for (var i in rslt.bookmarkInfo) if (parseInt(rslt.bookmarkInfo[i].xCoord)==list[number].x && parseInt(rslt.bookmarkInfo[i].yCoord)==list[number].y) {
        				document.getElementById('TSmistPlayer_'+list[number].x+'_'+list[number].y).innerHTML = rslt.bookmarkInfo[i].userName;
        				document.getElementById('TSmistCity_'+list[number].x+'_'+list[number].y).innerHTML = rslt.bookmarkInfo[i].cityName;
        			}
        			number++;
        			setTimeout(t.FetchTileID,750,number,total,list);
        			t.RemoveBookMark(number,list,rslt.bookmarkInfo[i].bookmarkId);
        		}
      		},
    	});
	},

	RemoveBookMark:function(number,list,bookmarkId){
		var t = Tabs.TurboSearch;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="REMOVE_BOOKMARK";
		params.bookmarkId=bookmarkId;
    	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        		}
      		},
    	});
	},

	doAddAttack : function (list){
	  	var t = Tabs.TurboSearch;
	  	for (var k=0;k<list.length;k++){		
	  		var coords = list[k].substr(14);
	  		var array = coords.split(',');
		  	if (array[0] != undefined && array[1] != undefined){
	  			var x = array[0];
	  			var y = array[1];
		  	}
	  	}
  	},

  	GetCoords : function (){
	    var t= Tabs.transport;
	    var targetName = "";
	    var targetCityName = "";
	    var total=0;
	    var units = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	    targetX = parseInt(document.getElementById ('ptcityX').value);
	    targetY = parseInt(document.getElementById ('ptcityY').value);
	    if (targetX =="" || targetY=="") {alert("Please enter coords...");return;}
	    var what = document.getElementById('TransportTroop').value;
	    what = what.substr(3);
	    if (parseInt(document.getElementById('TroopsToSend')) == 0) {alert("You got to send a least one troop...");return;}
	    units[what] = parseInt(document.getElementById('TroopsToSend').value);	

	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    	params.blocks = "bl_" + targetX + "_bt_" + targetY;
    	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			if (rslt.data["l_"+targetX+"_t_"+targetY].tileType == 51) {
        				userId = rslt.data["l_"+targetX+"_t_"+targetY].tileUserId;
        				if (userId != null) targetName = rslt.userInfo["u" + userId]["n"];
        				targetCityName = rslt.data["l_"+targetX+"_t_"+targetY].cityName;
        			}
        			MarchOptions.Queue.push ({
        				city: 			t.tcp.city.id,
        				action: 		1,
        				targetX: 		targetX,
        				targetY: 		targetY,
        				tileType: 		rslt.data["l_"+targetX+"_t_"+targetY].tileType,
        				tileLevel: 		rslt.data["l_"+targetX+"_t_"+targetY].tileLevel,
        				targetCityName: targetCityName,
        				targetName: 	targetName,
        				cityNumber: 	rslt.data["l_"+targetX+"_t_"+targetY].cityNum,
        				1: 				units[1],
        				2: 				units[2],
        				3: 				units[3],
        				4: 				units[4],
        				5: 				units[5],
        				6: 				units[6],
        				7: 				units[7],
        				8: 				units[8],
        				9: 				units[9],
        				10: 			units[10],
        				11: 			units[11],
        				12: 			units[12],
        				13: 			units[13],
        				14: 			units[14],
        				15: 			units[15],
        				r1: 			parseInt(document.getElementById ('pbtradeamountFood').value),
        				r2: 			parseInt(document.getElementById ('pbtradeamountWood').value),
        				r3: 			parseInt(document.getElementById ('pbtradeamountStone').value),
        				r4: 			parseInt(document.getElementById ('pbtradeamountOre').value),
        				r5: 			parseInt(document.getElementById ('pbtradeamountAstone').value),
        				gold: 			parseInt(document.getElementById ('pbtradeamountGold').value)
        			});
					saveMarchOptions();
					document.getElementById('TroopsToSend').value = 0;
					document.getElementById ('pbtradeamountFood').value == 0;
				    document.getElementById ('pbtradeamountWood').value == 0;
				    document.getElementById ('pbtradeamountStone').value == 0;
				    document.getElementById ('pbtradeamountOre').value == 0;
				    document.getElementById ('pbtradeamountAstone').value == 0;
				    document.getElementById ('pbtradeamountGold').value == 0;
					Dashboard.ShowMarches();
        		}
      		},
    	});
		
	},

	doAddScout : function (list){
	  	var t = Tabs.TurboSearch;
	  	var count = -1;
	  	var city="";
	  	slots = t.CheckCityMarches(t.from.city.id);
		rallypointlevel = getRallypoint(t.from.city.id);
	  	for (var k=0;k<list.length;k++){		
	  		var coords = list[k].substr(14);
	  		var array = coords.split(',');
	  		if (array[0] != undefined && array[1] != undefined){
	  			var x = array[0];
	  			var y = array[1];
		  		count++;
	  			setTimeout(t.doScout,1500*count, x,y,list[k]);
	  		}
	  	}
  	},

  	doScout : function (x,y,box) {
  	var t = Tabs.TurboSearch;
	  	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.cid= t.from.city.id;
	    params.type = 3
	    params.kid = 0
	    params.xcoord = x;
	    params.ycoord = y;
	  	params.u3 = 1;
	  	params.gold = 0;
	  	params.r1 = 0;
	  	params.r2 = 0;
	  	params.r3 = 0;
	  	params.r4 = 0;
	  	params.r5 = 0;
	  	 
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
			    method: "post",
			    parameters: params,
			    loading: true,
			    onSuccess: function (rslt) {
			        var t = Tabs.AllianceList;  
			        if (rslt.ok) {
			        	var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
				        var ut = unsafeWindow.unixtime();
				        var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
				        for(i = 0; i <= unitsarr.length; i++){
				           	if(params["u"+i]){
				             	unitsarr[i] = params["u"+i];
				           	}
				        }
				        var resources=new Array();
				        resources[0] = params.gold;
				        for(i=1; i<=4; i++){
				           	resources[i] = params["r"+i];
				        }
				        var currentcityid =  params.cid;
						var rtimediff=parseInt(rslt.returnTS)-parseInt(rslt.initTS);
	                 	//unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                  	unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, params.cid, true,ut+rtimediff);
				        unsafeWindow.update_seed(rslt.updateSeed)
				        if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
				        document.getElementById(box).checked = false;        
			        }
			    }, 
			    onFailure: function () {},
		});
  	},

	searchDone: function(data, userInfo, allianceNames, fromX, fromY, ProvinceSearch){
		var t = Tabs.TurboSearch;
		var dist = 0;
		mapDat = [];
		for (var i in data) {
			dist_i = distance(fromX, fromY, data[i].xCoord, data[i].yCoord)
			mapDat.push({
				xCoord: 		data[i].xCoord,
				yCoord: 		data[i].yCoord,
				dist: 			dist_i,
				tileType: 		data[i].tileType,
				tileLevel: 		data[i].tileLevel,
				tileUserId: 	data[i].tileUserId,
				cityName: 		data[i].cityName,
				tileCityId: 	data[i].tileCityId,
				cityNum:  		data[i].cityNum,
			});
		}
    	mapDat = mapDat.sort(function sort(a,b) {a = a['dist'];b = b['dist'];return a == b ? 0 : (a < b ? -1 : 1);});	
    	var checked = ((ProvinceSearch)?"unchecked":"checked");		
		var left = '<BR><input id=RadioCities type="radio" name="TStypes" value="Cities">Cities';
		left += '<BR><input id=RadioBarb type="radio" name="TStypes" value="Barb Camps">Barb Camps';
		left += '<BR><input id=RadioWild type="radio" name="TStypes" value="Wilderness">Wilderness:';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<select id=TSwildType>';
		left += '<option value=ALL>ALL</option><option value=99>Grass./Lake</option><option value=20>Woodland</option><option value=30>Hills</option><option value=40>Mountain</option><option value=50>Plain</option><option value=54>Dark Forest</option></select>';
		left += '<BR>___________________<BR>';
		left += '<INPUT type=checkbox id=TSunowned checked=true><SPAN id=DIVunowned></span>';
		left += '<BR><SPAN id=DIVminLevel></span><select id=TSminLevel>';
		for (var i=1;i<=10;i++) left+='<option value='+i+'>'+i+'</option>';
        left += '</select><BR><SPAN id=DIVmaxLevel></span><select id=TSmaxLevel>';
		for (var i=1;i<=10;i++) left+='<option value='+i+'>'+i+'</option>';
		left += '</select>';	
		left += '<BR>___________________<BR>';
		left += '<INPUT type=checkbox id=TSallied checked=true><SPAN id=DIVallied></span>';		
		left += '<BR>&nbsp&nbsp&nbsp&nbsp<INPUT type=checkbox id=TSmisted checked=true><SPAN id=DIVmisted></span>';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp<INPUT type=checkbox id=TShostile '+checked+'><SPAN id=DIVhostile></span>';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp<INPUT type=checkbox id=TSfriendly '+checked+'><SPAN id=DIVfriendly></span>';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp<INPUT type=checkbox id=TSfriendlyToUs '+checked+'><SPAN id=DIVfriendlyToUs></span>';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp<INPUT type=checkbox id=TSneutral '+checked+'><SPAN id=DIVneutral></span>';
		left += '<BR><INPUT type=checkbox id=TSunAllied '+checked+'><SPAN id=DIVunAllied></span>';
		left += '<BR><BR><SPAN id=DIVmight></span>';
		left += '<BR><SPAN id=DIVmightMin></span><INPUT id=TSmightMin size=4 maxlength=4 type=text value='+parseInt(Options.SearchMightMin)+'>';
		left += '<BR><SPAN id=DIVmightMax></span><INPUT id=TSmightMax size=4 maxlength=4 type=text value='+parseInt(Options.SearchMightMax)+'>';
		
		left += '<BR><BR><INPUT type=checkbox id=TSfilerTop disabled=true unchecked=true><SPAN id=DIVfilterTop></span>';
		left += '<BR>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<select id=TStopMin>';
		for (var i=1;i<=19;i++) left+='<option value='+i+'>'+i+'</option><';
		left += '</select>&nbsp&nbsp<SPAN id=DIVtop></span>&nbsp&nbsp<select id=TStopMax>';
		for (var i=2;i<=20;i++) left+='<option value='+i+'>'+i+'</option>';
		left += '</select>';	

		document.getElementById('TSleft').innerHTML = left;
      	document.getElementById('TSsearchButton').value = "Start Search";
      	document.getElementById('TSsearchButton').disabled = false;
      	document.getElementById('TSminLevel').addEventListener ('change', function (){
      		Options.srcMinLevel = document.getElementById('TSminLevel').value;
      		saveOptions();
      		t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);
      	}, false);
      	document.getElementById('TSmaxLevel').addEventListener ('change', function (){
      		Options.srcMaxLevel = document.getElementById('TSmaxLevel').value;
      		saveOptions();
      		t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);
      	}, false);
      	document.getElementById('TSmightMin').addEventListener ('change', function (){
      		Options.SearchMightMin = document.getElementById('TSmightMin').value;
      		saveOptions();
      		t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);
      	}, false);
      	document.getElementById('TSmightMax').addEventListener ('change', function (){
      		Options.SearchMightMax = document.getElementById('TSmightMax').value;
      		saveOptions();
      		t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);
      	}, false);
      	document.getElementById('TSfilerTop').addEventListener ('change', function (){
      		if (document.getElementById('TSfilerTop').disabled) {
      			document.getElementById('TStopMin').disabled = true;
				document.getElementById('TStopMax').disabled = true;
				document.getElementById('DIVfilterTop').innerHTML = '<FONT color=grey>Filter alliances Rank:</font>';
				document.getElementById('DIVtop').innerHTML = '<FONT color=grey>to</font>';
      		} else {
      			document.getElementById('TStopMin').disabled = false;
				document.getElementById('TStopMax').disabled = false;
				document.getElementById('DIVfilterTop').innerHTML = '<FONT color=black>Filter alliances Rank:</font>';
				document.getElementById('DIVtop').innerHTML = '<FONT color=black>to</font>';
      		}
      		t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);
      	}, false);

      	document.getElementById('RadioCities').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('RadioBarb').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('RadioWild').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSwildType').addEventListener ('change', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSunowned').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSmisted').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TShostile').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSfriendly').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSfriendlyToUs').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSneutral').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSallied').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TSunAllied').addEventListener ('click', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TStopMin').addEventListener ('change', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('TStopMax').addEventListener ('change', function (){t.checkData(mapDat, userInfo, allianceNames, fromX, fromY);}, false);
      	document.getElementById('RadioCities').checked = true;
      	document.getElementById('TSminLevel').value = Options.srcMinLevel;
      	document.getElementById('TSmaxLevel').value = Options.srcMaxLevel;
      	document.getElementById('TStopMin').value = 1;
      	document.getElementById('TStopMax').value = 10;
      	t.checkData(mapDat, userInfo, allianceNames, fromX, fromY)      	
	},

	checkData: function(mapDat, userInfo, allianceNames, fromX, fromY){
		var t = Tabs.TurboSearch;
		t.checkOptions();
		t.data=new Array();
		var Dip = Seed.allianceDiplomacies;
		var data = "<TABLE id=dbMain width=100% class=pbTab>";
		data += '<TR><TD><INPUT id=CheckAll type=checkbox unchecked=true></td><TD><B>Coords</b></td><TD><B>Dist</b></td><TD><B>Type (#)</b></td><TD><B>Lvl</b></td><TD><B>Might</b></td><TD>&nbsp</td><TD><B>Player</b></td><TD><B>Name</b></td><TD><B>Alliance</b></td></tr>';
      	var LastX=0;
      	var LastY=0;
      	for (var i in mapDat) {
      		if (mapDat[i].xCoord != undefined) {
      			var tileType = parseInt(mapDat[i].tileType);
      			if (document.getElementById('RadioCities').checked) {
      				if ((tileType == 51 || tileType== 53) && mapDat[i].tileCityId != null ) {
	      				var allianceID = 0;
	      				if (userInfo['u'+mapDat[i].tileUserId]) allianceID = parseInt(userInfo['u'+mapDat[i].tileUserId]["a"]);
	      				var diplomacy = 0;
	      				var Might = 0;
	      				if (userInfo['u'+mapDat[i].tileUserId]) Might = Math.round(userInfo['u'+mapDat[i].tileUserId]["m"]);
	      				var misted, hostile, friendly, friendlyToUs,neutral, allied, mightCheck, A_check;
	      				misted = hostile =  friendly = friendlyToUs = neutral = allied = mightCheck = A_check = false;
	      				var top = true;
	      				if (Dip.friendly && Dip.friendly['a'+allianceID]) diplomacy = 1;
		  				if (Dip.hostile && Dip.hostile['a'+allianceID]) diplomacy = 2;
		  				if (Dip.friendlyToYou && Dip.friendlyToYou['a'+allianceID]) diplomacy = 3;
		  				if (Dip.allianceId == allianceID) diplomacy = 1;
		  				if (allianceID > 0 || tileType== 53) allied =true;
		  				if (Might >= (Options.SearchMightMin*1000000) && Might <= (Options.SearchMightMax* 1000000)) mightCheck =true;
						if (document.getElementById('TSallied').checked && allied) A_check = true;
	      				 else if (document.getElementById('TSallied').checked && allied) A_check = false;
	      				if (document.getElementById('TSunAllied').checked && !allied) A_check = true;
	      				 else if (document.getElementById('TSunAllied').checked && !allied) A_check = false;
		  				if (document.getElementById('TSmisted').checked && tileType== 53) misted = true;
	      				 else if (document.getElementById('TSmisted').checked && tileType==51) misted = false;
	      				if (document.getElementById('TShostile').checked && diplomacy==2) hostile = true;
	      				 else if (document.getElementById('TShostile').checked && tileType==2) hostile = false;
	      				if (document.getElementById('TSfriendly').checked && diplomacy==1) friendly = true;
	      				 else if (document.getElementById('TSfriendly').checked && tileType==1) friendly = false;
	      				if (document.getElementById('TSfriendlyToUs').checked && diplomacy==3) friendlyToUs = true;
	      				 else if (document.getElementById('TSfriendlyToUs').checked && tileType==3) friendlyToUs = false;
	      				if (document.getElementById('TSneutral').checked && diplomacy==0) neutral = true;
	      				 else if (document.getElementById('TSneutral').checked && tileType==0) neutral = false;
	      				if (!allied) neutral = true;
	      				if (misted) mightCheck = true;
	      				if (document.getElementById('TSfilerTop').checked && t.rankings[allianceID] >= document.getElementById('TStopMin').value && t.rankings[allianceID] <= document.getElementById('TStopMax').value) top = false;
	      				var unique = true;
	      				if (parseInt(mapDat[i].xCoord)==LastX && parseInt(mapDat[i].yCoord)==LastY) unique=false;
      				 	LastX = parseInt(mapDat[i].xCoord);
      					LastY = parseInt(mapDat[i].yCoord);
	      				if ((misted || hostile || friendly || friendlyToUs ||  neutral) && A_check && mightCheck && top && unique) data += t.paintData(mapDat[i], userInfo, allianceNames, fromX, fromY);	
	      			}
      			}
      			if (document.getElementById('RadioBarb').checked) {
      				if (tileType == 51 && mapDat[i].tileCityId == null && parseInt(mapDat[i].tileLevel)>=Options.srcMinLevel && parseInt(mapDat[i].tileLevel)<=Options.srcMaxLevel) data += t.paintData(mapDat[i], userInfo, allianceNames, fromX, fromY);
      			}
      			if (document.getElementById('RadioWild').checked && tileType != 51 && tileType != 53) {
      				if (document.getElementById('TSunowned').checked && mapDat[i].tileCityId == null) var unownedOnly = true;
      				 else if (document.getElementById('TSunowned').checked) var unownedOnly = false;
      				  else var unownedOnly = true;
      				var filter = document.getElementById('TSwildType').value;
      				if ((tileType==10 || tileType==11) && filter==99) if (unownedOnly && parseInt(mapDat[i].tileLevel)>=Options.srcMinLevel && parseInt(mapDat[i].tileLevel)<=Options.srcMaxLevel)	data += t.paintData(mapDat[i], userInfo, allianceNames, fromX, fromY);
      				if (tileType == filter && unownedOnly && parseInt(mapDat[i].tileLevel)>=Options.srcMinLevel && parseInt(mapDat[i].tileLevel)<=Options.srcMaxLevel)	data += t.paintData(mapDat[i], userInfo, allianceNames, fromX, fromY);
					if (filter == "ALL" && unownedOnly && parseInt(mapDat[i].tileLevel)>=Options.srcMinLevel && parseInt(mapDat[i].tileLevel)<=Options.srcMaxLevel)	data += t.paintData(mapDat[i], userInfo, allianceNames, fromX, fromY);
      			}  

   	      	}
      	}
      	document.getElementById('TSright').innerHTML = data;
      	document.getElementById('CheckAll').addEventListener ('change', t.doSelectall, false);
      	var uList = [];
	    for(k in mapDat) if(mapDat[k].tileUserId != null) uList.push(mapDat[k].tileUserId);
	    t.fetchPlayerStatus(uList);
	},

	doSelectall : function (){
   		var t = Tabs.TurboSearch;
  		var element_class = document.getElementsByClassName('TSscout');
		for (k=0;k<element_class.length;k++) ((element_class[k].checked)?element_class[k].checked=false:element_class[k].checked=true)
  	},

	paintData: function(mapDat, userInfo, allianceNames, fromX, fromY){
  		var t = Tabs.TurboSearch;
   		var Dip = Seed.allianceDiplomacies;
   		t.data.push({mapDat:mapDat})
   		//Checkbox
   		data = '<TR><TD><INPUT class=TSscout id=ScoutCheckbox_'+mapDat.xCoord+","+mapDat.yCoord+' type=checkbox unchecked=true></td>'; 
   		//Coords
   		data+= '<TD>'+coordLink(mapDat.xCoord,mapDat.yCoord)+'</td>';
  		//Distance
  		data+= '<TD>'+mapDat.dist+'</td>';
  		//Tile Type
  		var tileType = parseInt(mapDat.tileType);
  		if (tileType == 51 && mapDat.tileCityId == null) tileType = 'Barb Camp';
  		 else tileType = t.tileTypes[parseInt(mapDat.tileType)];
  		data+= '<TD>'+tileType;
  		if (parseInt(mapDat.tileType) == 51 && mapDat.tileCityId != null) data += ' (' + mapDat.cityNum+ ')'; 
  		data+= '</td>';
  		//Tile Level
  		if (mapDat.tileLevel > 0) data+= '<TD>'+mapDat.tileLevel+'</td>';
  		else data+= '<TD>??</td>';	
  		//Might
  		if (mapDat.tileUserId != null && mapDat.tileUserId != 0) data+= '<TD align=right>'+addCommas(Math.round(parseInt(userInfo['u'+mapDat.tileUserId]["m"])))+'</td>';
  		  else data+= '<TD></td>';
  		//Space
  		data+='<TD>&nbsp</td>';
  		//Player
  		if (mapDat.tileUserId != null && mapDat.tileUserId != 0) data+= '<TD><SPAN class="DIVonline_'+mapDat.tileUserId+'"></span>'+userInfo['u'+mapDat.tileUserId]["n"]+'</td>';
  		 else if (mapDat.tileUserId == 0) data+= '<TD>???</td>';
  		  else data+= '<TD>---</td>';
  		//City Name
  		if (mapDat.cityName != null) data+= '<TD>'+mapDat.cityName+'</td>';
  		else if (mapDat.tileUserId == 0) data+= '<TD>???</td>';
  		 else data+= '<TD>---</td>';
  		//Alliance Name
  		if (mapDat.tileUserId != null && mapDat.tileUserId != 0) {
  			var allianceID = userInfo['u'+mapDat.tileUserId]["a"];
  			if (allianceID != 0) {
  				var color = "black";
  				if (Dip.friendly && Dip.friendly['a'+allianceID]) color = "green";
  				if (Dip.hostile && Dip.hostile['a'+allianceID]) color = "red";
  				if (Dip.friendlyToYou && Dip.friendlyToYou['a'+allianceID]) color = "orange";
  				if (Dip.allianceId == allianceID) color = "blue";
  				data+= '<TD><FONT color='+color+'>'+allianceNames['a'+allianceID]+'</font></td>'; 
  			} else data+= '<TD>---</td>'; 
  		} else if (mapDat.tileUserId == 0) data+= '<TD>???</td>';
  		   else if (parseInt(mapDat.tileType) == 51 && mapDat.tileCityId == null) { 
		   data+='<TD><A onclick="pbExportToRaid('+ mapDat.xCoord +','+ mapDat.yCoord +')">Export</td>';
		   data+='<TD><A onclick="GoToAttackTab('+ mapDat.xCoord +','+ mapDat.yCoord +','+ t.from.city.id +')">AutoAtk</td>';
		   }
  		  	else data+= '<TD>---</td>';	
      	return data;
	},

	ExportToRaid : function (X,Y){
		var t = Tabs.TurboSearch;
		var cityId = t.from.city.id;
	    var pop = new pbPopup ('pbExportRaid', 0,0, 750,255, true);
	    if (t.popFirst){pop.centerMe (mainPop.getMainDiv());  t.popFirst = false;}
	    pop.getTopDiv().innerHTML = '<CENTER><B>Export to Raid</b></center>';   
	    var m = '<TABLE id=pbRaidAdd width=100% height=0% class=pbTab><TR>';      
	    for (i=1;i<=5;i++)		m+='<TD rowspan="2"><img src="//kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"><TD align=left>'+ addCommas(Seed.units['city'+cityId]['unt'+i]) +'</td>';
		m+='</tr><TR>';
		for (i=1;i<=5;i++)		m+='<TD><INPUT id="Unit'+i+'" type=text size=6 maxlength=6 value="0"></td>';
	    m+='</tr><TR>';
		for (i=6;i<=10;i++)		m+='<TD rowspan="2"><img src="//kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"><TD align=left>'+ addCommas(Seed.units['city'+cityId]['unt'+i]) +'</td>';
		m+='</tr><TR>';
		for (i=6;i<=10;i++)		m+='<TD><INPUT id="Unit'+i+'" type=text size=6 maxlength=6 value="0"></td>';
	    m+='</tr><TR>';
		for (i=11;i<=15;i++)	m+='<TD rowspan="2"><img src="//kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545"><TD align=left>'+ addCommas(Seed.units['city'+cityId]['unt'+i]) +'</td>';
		m+='</tr><TR>';
		for (i=11;i<=15;i++)	m+='<TD><INPUT id="Unit'+i+'" type=text size=6 maxlength=6 value="0"></td>';
	    m+='</tr></table>';
	    m+= '<BR><CENTER>' +strButton20(translate('Help'), 'id=pbHelp')+'<SELECT id=RaidKnights type=list></select></center>';
	    m+= '<BR><CENTER>'+ strButton20(translate('Raid and save'), 'id=pbRaidSave') +'</center>';        
	    pop.getMainDiv().innerHTML = m;
	    t.getKnights(); 
	    document.getElementById ('pbHelp').addEventListener ('click', t.helpPop, false);
	    document.getElementById ('pbRaidSave').addEventListener ('click', function(){
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);                       
        params.pf = 0;
        params.ctrl = 'BotManager';
        params.action = 'saveMarch';
        params.settings = {};
        params.settings.cityId = cityId;
        params.queue = {0:{botMarches:{botMarchStatus:1,botState:1},cityMarches:{}}};        
        params.queue[0].cityMarches.knightId = parseInt(document.getElementById ('RaidKnights').value);
        params.queue[0].cityMarches.toXCoord = X;
        params.queue[0].cityMarches.toYCoord = Y;
        params.queue[0].cityMarches.unit0Count = 0;
        for (var i=1;i<=15;i++) params.queue[0].cityMarches['unit'+i+'Count'] = parseInt(document.getElementById ('Unit'+i).value);	
         
		new AjaxRequest2(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                      method: "post",
                     parameters: params,
                     loading: true,
                     onSuccess: function(transport){
                        var rslt = eval("(" + transport.responseText + ")");
                        if (rslt.ok) {
                            pop.show (false);
                            unsafeWindow.cityinfo_army();
                          	setTimeout(unsafeWindow.update_seed_ajax, 250);
                        } else ('Error :' + rslt.msg);
                     },
             });
        }, false); 
    	pop.show (true);
	},

	getKnights : function(){
        var t = Tabs.TurboSearch;
        var knt = new Array();
        cityId = t.from.city.id;
	    for (k in Seed.knights['city' + cityId]){
            if (Seed.knights['city' + cityId][k]["knightStatus"] == 1 && Seed.leaders['city' + cityId]["resourcefulnessKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["politicsKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["combatKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["intelligenceKnightId"] != Seed.knights['city' + cityId][k]["knightId"]){
                knt.push ({Name:   Seed.knights['city' + cityId][k]["knightName"],Combat:    parseInt(Seed.knights['city' + cityId][k]["combat"]),ID:        Seed.knights['city' + cityId][k]["knightId"],});
            }
	    }
        knt = knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
        document.getElementById('RaidKnights').options.length=0;
        var o = document.createElement("option");
        o.text = '--Choose a Knight--';
        o.value = 0;
        document.getElementById("RaidKnights").options.add(o);
        for (k in knt){
            if (knt[k]["Name"] !=undefined){
                var o = document.createElement("option");
                o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +')')
                o.value = knt[k]["ID"];
                document.getElementById("RaidKnights").options.add(o);
            }
        }
    },

    helpPop : function (){
       var helpText = '<A target="_tab" href="http://koc.wikia.com/wiki/Barbarian_Camps">A lot more can be found on Koc Wikia</a>';
       helpText += '<TABLE><TR><TD>Lvl</td><TD>Troops</td></tr>';
       helpText += '<TR><TD>1</td><TD>500 Supply Troops + 500 Archers</td></tr>';
       helpText += '<TR><TD>2</td><TD>500 Supply Troops + 2500 Archers</td></tr>';
       helpText += '<TR><TD>3</td><TD>500 Supply Troops + 5000 Archers</td></tr>';
       helpText += '<TR><TD>4</td><TD>500 Supply Troops + 7500 Archers</td></tr>';
       helpText += '<TR><TD>5</td><TD>15000 Archers</td></tr>';
       helpText += '<TR><TD>5</td><TD>12000 Archers IF Level 10 fletching and Level 9 Featherweight</td></tr>';
       helpText += '<TR><TD>6</td><TD>25000 Archers IF Level 9 fletching</td></tr>';
       helpText += '<TR><TD>6</td><TD>22000 Archers IF Level 10 fletching</td></tr>';
       helpText += '<TR><TD>7</td><TD>45000 Archers IF Level 10 fletching</td></tr>';
       helpText += '<TR><TD>7</td><TD>44000 Archers IF Level 10 fletching and knight 69+</td></tr>';
       helpText += '<TR><TD>7</td><TD>40000 Archers IF Level 10 fletching and knight 94+</td></tr>';
       helpText += '<TR><TD>8</td><TD>28000 Ballista WITH Level 10 fletching and Knight 91+</td></tr>';
       helpText += '<TR><TD>9</td><TD>56000 Ballista WITH Level 10 fletching and Knight 98+</td></tr>';
       helpText += '<TR><TD>10</td><TD>125000 Catapults (500 Catapults loss!)</td></tr></tr></table>';
       var pop = new pbPopup ('giftHelp', 0, 0, 400, 350, true);
       pop.centerMe (mainPop.getMainDiv());  
       pop.getMainDiv().innerHTML = helpText;
       pop.getTopDiv().innerHTML = '<CENTER><B>AIO Script '+translate("Help")+': '+translate("Raids")+'</b></center>';
       pop.show (true);
    },

	doSearch: function(blocks,fromX,fromY,number,count){
		var t = Tabs.TurboSearch;
		document.getElementById('TSsearchButton').value = count + '/' + Math.ceil(number/9);

		if (blocks.length <= 0) {
			t.searchDone(t.data, t.userInfo, t.allianceNames, fromX, fromY, false);
			return;
		}
		count++;
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.blocks = blocks.splice(0, 9);
		
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
	  		method: "post",
	  		parameters: params,
	  		onSuccess: function (transport) {
	  			var rslt = eval("(" + transport.responseText + ")");
	    		if (rslt.ok) {
	    			if (rslt.data == []) alert("MAP ERROR");


	    			 else {
					 for (var r in rslt.data) t.data.push(rslt.data[r]);
					 for (var r in rslt.userInfo) {t.userInfo[r]=rslt.userInfo[r]};
					 for (var r in rslt.allianceNames) {t.allianceNames[r]=rslt.allianceNames[r]};
					 setTimeout(t.doSearch, 500, blocks, fromX, fromY,number,count);
					 }
	    		}
	  		},
	  		onFailure: function () {
	  			alert('Search Failed');
	  			document.getElementById('TSsearchButton').value = "Start Search";
      			document.getElementById('TSsearchButton').disabled = false;
	  		},	
		});
	},

	ProvinceSearch:function(blocks,fromX,fromY,number){
		var t = Tabs.TurboSearch;
		if (number==26) {t.searchDone(t.data,t.userInfo,t.allianceNames,fromX,fromY,true);return;}
		document.getElementById('TSsearchButton').value = number + '/25';
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.blocks = blocks[number];
		
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
	  		method: "post",
	  		parameters: params,
	  		onSuccess: function (transport) {
	  			var rslt = eval("(" + transport.responseText + ")");
	    		if (rslt.ok) {
	    			if (rslt.data == []) alert("MAP ERROR");
	    			 else {
	    			 	for (var r in rslt.data) t.data.push(rslt.data[r]);
						for (var r in rslt.userInfo) {t.userInfo[r]=rslt.userInfo[r]};
						for (var r in rslt.allianceNames) {t.allianceNames[r]=rslt.allianceNames[r]};
	    			 	number++;  			 	
	    			 	setTimeout(t.ProvinceSearch,500,blocks,fromX,fromY,number);
	    			 }
	    		}
	  		},
	  		onFailure: function () {
	  			alert('Search Failed');
	  			document.getElementById('TSsearchButton').value = "Start Search";
      			document.getElementById('TSsearchButton').disabled = false;
	  		},	
		});

	},

	fetchPlayerStatus : function (uidArray){
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	    params.checkArr = uidArray.join(',');
	    
	    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
	      method: "post",
	      parameters: params,
	      onSuccess: function (rslt) {
	      		if (rslt.ok) for (var y in rslt.data) {
	      			if (rslt.data[y]) var status = '<img src=""/>';      
	      			 else var status = '<img src=""/>';    
	        		var element = document.getElementsByClassName('DIVonline_'+y);
				    for (var k=0;k<element.length;k++) element[k].innerHTML = status;	      
	        	}	
	      },
	      onFailure: function () {},
	    });
  	},

	checkOptions: function(){
		var t = Tabs.TurboSearch;
		if (document.getElementById('RadioCities').checked){
			document.getElementById('DIVminLevel').innerHTML = '<FONT color=grey>Min. Level: </font>';
			document.getElementById('DIVmaxLevel').innerHTML = '<FONT color=grey>Max. Level: </font>';
			document.getElementById('DIVunowned').innerHTML = '<FONT color=grey>Unowned</font>';
			document.getElementById('TSunowned').disabled = true;
			document.getElementById('TSminLevel').disabled = true;
			document.getElementById('TSmaxLevel').disabled = true;
			t.enableCityOptions();
		} 
		if (document.getElementById('RadioBarb').checked || document.getElementById('RadioWild').checked) {
			document.getElementById('DIVminLevel').innerHTML = '<FONT color=black>Min. Level: </font>';
			document.getElementById('DIVmaxLevel').innerHTML = '<FONT color=black>Max. Level: </font>';
			if (document.getElementById('RadioBarb').checked) {
				document.getElementById('DIVunowned').innerHTML = '<FONT color=grey>Unowned</font>';
				document.getElementById('TSunowned').disabled = true;
			} else {
				document.getElementById('DIVunowned').innerHTML = '<FONT color=black>Unowned</font>';
				document.getElementById('TSunowned').disabled = false;
			}
			document.getElementById('TSminLevel').disabled = false;
			document.getElementById('TSmaxLevel').disabled = false;
			t.disableCityOptions();
		}
	},

	disableCityOptions: function(){
		document.getElementById('DIVmisted').innerHTML = '<FONT color=grey>Misted</font>';
		document.getElementById('DIVhostile').innerHTML = '<FONT color=grey>Hostile</font>';
		document.getElementById('DIVfriendly').innerHTML = '<FONT color=grey>Friendly / Us</font>';
		document.getElementById('DIVfriendlyToUs').innerHTML = '<FONT color=grey>Friendly To Us</font>';
		document.getElementById('DIVneutral').innerHTML = '<FONT color=grey>Neutral</font>';
		document.getElementById('DIVallied').innerHTML = '<FONT color=grey>Allied</font>';
		document.getElementById('DIVunAllied').innerHTML = '<FONT color=grey>Unallied</font>';
		document.getElementById('DIVmight').innerHTML = '<FONT color=grey>Might (in Million):</font>';
		document.getElementById('DIVmightMin').innerHTML = '<FONT color=grey>Min.:</font>';
		document.getElementById('DIVmightMax').innerHTML = '<FONT color=grey>Max.:</font>';
		document.getElementById('DIVfilterTop').innerHTML = '<FONT color=grey>Filter alliances Rank:</font>';
		document.getElementById('DIVtop').innerHTML = '<FONT color=grey>to</font>';
		document.getElementById('TSmisted').disabled = true;
		document.getElementById('TShostile').disabled = true;
		document.getElementById('TSfriendly').disabled = true;
		document.getElementById('TSfriendlyToUs').disabled = true;
		document.getElementById('TSneutral').disabled = true;
		document.getElementById('TSallied').disabled = true;
		document.getElementById('TSunAllied').disabled = true;
		document.getElementById('TSmightMin').disabled = true;
		document.getElementById('TSmightMax').disabled = true;
		document.getElementById('TSfilerTop').disabled = true;
		document.getElementById('TStopMin').disabled = true;
		document.getElementById('TStopMax').disabled = true;
	},
	enableCityOptions: function(){
		if (document.getElementById('TSallied').checked){
			document.getElementById('TSmisted').disabled = false;
			document.getElementById('TShostile').disabled = false;
			document.getElementById('TSfriendly').disabled = false;
			document.getElementById('TSfriendlyToUs').disabled = false;
			document.getElementById('TSneutral').disabled = false;
			document.getElementById('DIVmisted').innerHTML = '<FONT color=black>Misted</font>';
			document.getElementById('DIVhostile').innerHTML = '<FONT color=red>Hostile</font>';
			document.getElementById('DIVfriendly').innerHTML = '<FONT color=green>Friendly</font>&nbsp/&nbsp<FONT color=blue>Us</font>';
			document.getElementById('DIVfriendlyToUs').innerHTML = '<FONT color=orange>Friendly To Us</font>';
			document.getElementById('DIVneutral').innerHTML = '<FONT color=black>Neutral</font>';
		} else {
			document.getElementById('TSmisted').disabled = true;
			document.getElementById('TShostile').disabled = true;
			document.getElementById('TSfriendly').disabled = true;
			document.getElementById('TSfriendlyToUs').disabled = true;
			document.getElementById('TSneutral').disabled = true;
			document.getElementById('DIVmisted').innerHTML = '<FONT color=grey>Misted</font>';
			document.getElementById('DIVhostile').innerHTML = '<FONT color=grey>Hostile</font>';
			document.getElementById('DIVfriendly').innerHTML = '<FONT color=grey>Friendly</font>';
			document.getElementById('DIVfriendlyToUs').innerHTML = '<FONT color=grey>Friendly To Us</font>';
			document.getElementById('DIVneutral').innerHTML = '<FONT color=grey>Neutral</font>';
		}
		document.getElementById('DIVallied').innerHTML = '<FONT color=black>Allied</font>';
		document.getElementById('DIVunAllied').innerHTML = '<FONT color=black>Unallied</font>';
		document.getElementById('DIVmight').innerHTML = '<FONT color=black>Might (in Million):</font>';
		document.getElementById('DIVmightMin').innerHTML = '<FONT color=black>Min.:</font>';
		document.getElementById('DIVmightMax').innerHTML = '<FONT color=black>Max.:</font>';
		document.getElementById('DIVfilterTop').innerHTML = '<FONT color=black>Filter alliances Rank:</font>';
		document.getElementById('DIVtop').innerHTML = '<FONT color=black>to</font>';
		document.getElementById('TSallied').disabled = false;
		document.getElementById('TSunAllied').disabled = false;
		document.getElementById('TSmightMin').disabled = false;
		document.getElementById('TSmightMax').disabled = false;
		document.getElementById('TSfilerTop').disabled = false;
		document.getElementById('TStopMin').disabled = false;
		document.getElementById('TStopMax').disabled = false;
	},

	show: function (){
		var t = Tabs.TurboSearch;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	    params.pageNo = 1;
	    params.cityId = unsafeWindow.currentcityid;
	     
	    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetOtherInfo.php" + unsafeWindow.g_ajaxsuffix, {
		    method: "post",
		    parameters: params,
		    onSuccess: function (rslt) {
				var data = rslt.otherAlliances;
				for (y=0;y<data.length;y++) t.rankings[data[y].allianceId] = data[y].ranking; 
					var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
				    params.pageNo = 2;
				    params.cityId = unsafeWindow.currentcityid;
				     
				    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetOtherInfo.php" + unsafeWindow.g_ajaxsuffix, {
				      	method: "post",
				      	parameters: params,
				      	onSuccess: function (rslt) {
						  	var data = rslt.otherAlliances;
						  	for (y=0;y<data.length;y++) t.rankings[data[y].allianceId] = data[y].ranking; 
				      	},
				    });
		    },
	    });
	},
	hide: function (){}
}

/************************  Overview Tab ************************/
var OverviewTabActive = false;

Tabs.Overview = {
	tabOrder: 1,
	tabLabel: 'Overview',
	type: 'Tools',
	myDiv: null,
//  var mmb = unsafeWindow.cm.mww.chooseMmbCard();
    init: function(div){
    	var t = Tabs.Overview;
        t.myDiv = div;
        dt = new Date ();
    	dt.setTime (Seed.player.datejoinUnixTime * 1000);
      
           var nonW =0;
          var brokecount =0;
          var count =0;
          var broketotal =0;
           var mtotc=0;
 for (k in unsafeWindow.kocThroneItems) {
			count++;
			ActiveItems = parseInt(Seed.throne.rowNum)*5;
			if (count > ActiveItems) break;
			y = unsafeWindow.kocThroneItems[k];
      var z = y.quality;
      var zz = y.level;
      
			if (y.isBroken) {brokecount++;
      if (z < 5) nonW++;
      mtotc= unsafeWindow.cm.thronestats.mightByQuality[z].Might+unsafeWindow.cm.thronestats.mightByLevel[zz].Might;
     broketotal += mtotc;
     
      }
     
		}	
      	var m = '<DIV class=pbStat><TABLE width=100% height=0% class=pbTab>';
        
      	m+= '<TR align=left><TD>Joined on: <br>'+ dt.toLocaleDateString() +'</td>';
        	m+= '<TD>Might: <br>' + addCommas(parseInt(Seed.player.might)) +'</td>';
          m+='<TD align=center><SPAN class=boStatLight>'+'T R:'+count+' <br>'+addCommas(unsafeWindow.cm.ThroneController.calcMight())+'</span></td>';
          var dif= unsafeWindow.cm.ThroneController.calcMight()-broketotal;


	
    
      m+= '<TD>broken:'+brokecount+'<br> '+addCommas(broketotal)+'<BR>'+addCommas(dif)+'<BR>non-wonder : '+nonW+'</td>';
      
      	m+= '<TD>Alliance:<br> ' + getMyAlliance()[1] +'</td>';
        
     	m+= '<TD align=right>Domain: <br>' + unsafeWindow.domainName +'</td></tr></table></div><BR>';      
      	m+= '<DIV id=Stats></div><BR>';
      	m+= '<DIV id=TroopStats></div>';
      	m+= '<DIV id=O_Options></div><BR>';
       	t.myDiv.innerHTML = m;    	
    },
    paintStats: function(){
    	var t = Tabs.Overview;
      var STOREHOUSE = [0,100000,200000,300000,400000,500000,600000,700000,800000,900000,1000000,5000000,50000000];
			var MAXST =	unsafeWindow.cm.ThroneController.effectBonus(89);
			if (MAXST > 1250) MAXST = 1250;	
      
    	m= '<TABLE width=100% height=0% class=pbTab><TR valign=top align=right><TD></td><TD style="background: #ffc">TOTAL</td>';
     	for (var i=0;i<Seed.cities.length;i++) {
      if (Seed.cityData.city[Seed.cities[i][0]].isPrestigeCity) {
	  					var atype = Seed.cityData.city[Seed.cities[i][0]].prestigeInfo.prestigeType;
	  					var alevel = Seed.cityData.city[Seed.cities[i][0]].prestigeInfo.prestigeLevel;
	  					var avalue = Seed.cityData.city[Seed.cities[i][0]].cityValue;
          }
     		m+='<TD><b>'+Seed.cities[i][1] + '</b>';
     		m+='<BR>'+coordLink(Seed.cities[i][2],Seed.cities[i][3]);
     		m+='<BR>'+unsafeWindow.provincenames['p'+Seed.cities[i][4]];
        if (atype == 1) {
	  						m+= '<br>Druid  ';
	  					} else if (atype == 2) {
	  						m+= '<br>Fey   ';
	  					} else {
	  						m+= '<br>Briton  ';
	  					}
        m+= 'Lvl '+alevel;
         //unsafeWindow.seed.citystats["city"+Cities.cities[i].id].pop[0]
         
         
        
         
         if(getCityPrestige(Seed.cities[i][0])){
        m+= '<BR><img height =  18 src=http://kabam1-a.akamaihd.net/silooneofcamelot/fb/e2/src/img/buildings/storehouse_lvl10_26.png>'+ parseInt((50*(1+ Seed.tech.tch14/10) * (1+MAXST/100)))+'mil';
        }
        else{
			m+= '<BR>'+addCommas((STOREHOUSE[getCityBuilding(Seed.cities[i][0],9).maxLevel]* (1 +Seed.tech.tch14/10)*(1+MAXST/100)));
			}	
				
         
        }
     	
     	m+='</tr>';
     	for (var i=0;i<=5;i++){
     		var resourceinfo = unsafeWindow.resourceinfo[i];
     		var total=0;
        
        if (i==5) resourceinfo = unsafeWindow.resourceinfo[7]; 
     		m+='<TR><TD><B>'+resourceinfo+'</b></td>';
     		if (i==0) m+= t.paintGold();
     		 else m+= t.paintRec(i);
     	}
    
     	m+='</tr><TR style="height:5px;max-height:5px"><TD colspan=10 style="height:100%;border-bottom: 1px dashed #000000;"></td></tr>';
      
     	m+='<TR style="height:4px;max-height:4px"><TD colspan=10 style="height:100%"></td></tr>';
     	m+= t.paintTroops();
     	m+='<TR style="height:5px;max-height:5px"><TD colspan=10 style="height:100%;border-bottom: 1px dashed #000000;"></td></tr>';
     	m+='<TR style="height:4px;max-height:4px"><TD colspan=10 style="height:100%"></td></tr>';
     	m+= '<TR><TD><B>Food Usage</b></td>';
     	var total = 0;
      var poptotal =0;
     	for (var ii=0;ii<Seed.cities.length;ii++) {
        var usade2 = unsafeWindow.cm.Resources.getProduction(1,Cities.cities[ii].id);
     		var usage = t.getFoodUsage(ii);
         
    total+= usade2;
    
     	}
     
     	m+= '<TD  style="text-align:right;background: #ffc">'+addCommas(total)+'</td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
       var usade2 = unsafeWindow.cm.Resources.getProduction(1,Cities.cities[ii].id);
     		var usage = t.getFoodUsage(ii);
        
          m+= '<TD style="text-align:right;">'+addCommas(usade2)+'</td>';
     	}
      m+= '</tr><TR><TD><B>Food Left</b></td><TD></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		var usage = unsafeWindow.cm.Resources.getProduction(1,Cities.cities[ii].id);
     		if (usage > 0) m+='<TD style="text-align:right;">----</td>';
     		 else {
     		 	var timeLeft = parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec1'][0]) / (0-usage);
     		 	if (timeLeft < (3600*24)) m+='<TD style="text-align:right;"><SPAN style="padding-left:3px; padding-right:3px; background-color:#700; color:white; font-weight:bold">'+ timestrShort(timeLeft) +'</span></td>';
     		 	 else m+='<TD style="text-align:right;">'+ timestrShort(timeLeft) +'</td>';
     		}
     	}
     	m+= '<TR><TD><B>ore prod</b></td>';
      var total2 = 0;
      var poptotal =0;
      var poptotal2 =0;
     	for (var ii=0;ii<Seed.cities.length;ii++) {
        var usade3 = unsafeWindow.cm.Resources.getProduction(4,Cities.cities[ii].id);
     		 poptotal += unsafeWindow.seed.citystats["city"+Cities.cities[ii].id].pop[1];
         poptotal2 += unsafeWindow.seed.citystats["city"+Cities.cities[ii].id].pop[0];
     		total2+= usade3;
     	}
      m+= '<TD  style="text-align:right;background: #ffc">'+addCommas(total2)+'</td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		var usage3 = unsafeWindow.cm.Resources.getProduction(4,Cities.cities[ii].id);
     	   m+= '<TD style="text-align:right;">'+addCommas(usage3)+'</td>';
     	
     	}
     m+= '<TR><TD><B>Max pop<BR>Curr Pop</b></td>';
     m+= '<TD  style="text-align:right;background: #ffc">'+addCommas(parseInt(poptotal))+'<BR>'+addCommas(parseInt(poptotal2))+'</td>';
     
    for (var ii=0;ii<Seed.cities.length;ii++){
     var popcitytot= unsafeWindow.seed.citystats["city"+Cities.cities[ii].id].pop[1];
        ;
        var popcitytot2= unsafeWindow.seed.citystats["city"+Cities.cities[ii].id].pop[0];
        ;
     m+= '<TD style="text-align:right;">'+addCommas(parseInt(popcitytot))+'<BR>'+addCommas(parseInt(popcitytot2))+'</td>';
     }
     
      
      
      
      
     	m+='</tr><TR style="height:5px;max-height:5px"><TD colspan=10 style="height:100%;border-bottom: 1px dashed #000000;"></td></tr>';
     	m+='<TR style="height:4px;max-height:4px"><TD colspan=10 style="height:100%"></td></tr>';
     	m+='<TR><TD><B>#Wilds</b></td><TD></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		var wilds = 0;
     		var castle = parseInt(Seed.buildings['city'+ Seed.cities[ii][0]].pos0[1]);
       		if(castle == 11) castle = 12;
       		 else if(castle == 12) castle = 14;
     		if (Seed.wilderness['city'+ Seed.cities[ii][0]]!=null && matTypeof(Seed.wilderness['city'+ Seed.cities[ii][0]])=='object') for (var k in Seed.wilderness['city'+ Seed.cities[ii][0]]) wilds++;
     		if (wilds < castle) m+='<TD style="text-align:right;"><FONT color=red>'+wilds+'/'+castle+'</font></td>';
     		 else m+='<TD style="text-align:right;">'+wilds+'/'+castle+'</td>';
     	}
     	m+= '</tr><TR><TD><B># Knights</b></td><TD></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		var Knights = 0;
            for (k in Seed.knights['city'+ Seed.cities[ii][0]]) Knights++;
            m+='<TD style="text-align:right;">'+Knights+'</td>';
     	}
     	m+= '</tr><TR><TD><B>TroopQ</b></td><TD></td>';
     	var now = unixTime();
     	for (var ii=0;ii<Seed.cities.length;ii++) {	
			if (getCityBuilding(Seed.cities[ii][0],13).count>0) {
				if (Seed.queue_unt['city'+Seed.cities[ii][0]]!=null && Seed.queue_unt['city'+Seed.cities[ii][0]].length>0) TroopTime = Seed.queue_unt['city'+Seed.cities[ii][0]][Seed.queue_unt['city'+Seed.cities[ii][0]].length-1][3] - now;
				else TroopTime = 0;
				if (TroopTime == 0) m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
				 else m+='<TD style="text-align:right;">'+timestr(TroopTime)+'</td>';
			} else m+='<TD style="text-align:right;">----</td>';
     	}
     	m+= '</tr><TR><TD><B>WallQ</b></td><TD></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		var wall = {};
	        getWallInfo (Seed.cities[ii][0], wall);
	        var WallTime = 0;
	        var q = Seed.queue_fort['city'+Seed.cities[ii][0]]; 
	        if (Seed.queue_fort['city'+Seed.cities[ii][0]]!=null && Seed.queue_fort['city'+Seed.cities[ii][0]].length>0) WallTime = Seed.queue_fort['city'+Seed.cities[ii][0]][Seed.queue_fort['city'+Seed.cities[ii][0]].length-1][3] - now;
	        if (WallTime < 0) WallTime = 0;
	        if (WallTime==0 && (wall.wallSpaceUsed < wall.wallSpace-4 || wall.fieldSpaceUsed < wall.fieldSpace-4)) m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
			 else if (WallTime >0) m+='<TD style="text-align:right;">'+timestr(WallTime)+'</td>';
			  else m+='<TD style="text-align:right;">----</td>';
     	}
     	m+= '</tr><TR><TD><B>CraftQ</b></td><TD></td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		if (getCityBuilding(Seed.cities[ii][0],20).count>0) {
     			if (Seed.queue_craft['city'+Seed.cities[ii][0]]!=null && Seed.queue_craft['city'+Seed.cities[ii][0]].length>0) {
     				var CraftTime = Seed.queue_craft['city'+Seed.cities[ii][0]][0].craftingEtaUnixTime - now;
     				if (CraftTime<0) CraftTime=0;
     				if (CraftTime == 0) m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
					 else m+='<TD style="text-align:right;">'+timestr(CraftTime)+'</td>';
     			} else m+='<TD style="text-align:right;"><FONT color=red>0s</font></td>';
     		} else m+='<TD style="text-align:right;">----</td>';
     	}
     	m+= '</tr></table>';	
     	document.getElementById('Stats').innerHTML = m;
    },
    paintGold:function(){
    	var gold = "";
    	var total=0;
    	for (var ii=0;ii<Seed.cities.length;ii++) total += parseInt(Seed.citystats['city'+Seed.cities[ii][0]].gold[0]);
     	gold += '<TD style="text-align:right;background: #ffc">'+addCommas(total)+'</td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) gold+='<TD style="text-align:right;">'+addCommas(parseInt(Seed.citystats['city'+Seed.cities[ii][0]].gold[0]))+'</td>';
		return gold; 
    },
    paintRec:function(i){
    	var t = Tabs.Overview;
    	var rec = "";
    	var total=0;
    	for (var ii=0;ii<Seed.cities.length;ii++) {
    		if (i==5) total += parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec'+i][0]);
    		 else total += Math.round(parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec'+i][0])/3600);
    	}
     	if (i!=5) rec += '<TD style="text-align:right;background: #ffc"><a class=hasTooltip style="color:black">'+addCommas(total)+'<SPAN>'+t.getTotalTransporting(i)+'</span></a></td>';
     	else rec += '<TD style="text-align:right;background: #ffc">'+addCommas(total)+'</td>';
     	for (var ii=0;ii<Seed.cities.length;ii++) {
     		if (i==5) rec+='<TD style="text-align:right;">'+addCommas(parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec'+i][0]))+'</td>';
     		else rec+='<TD style="text-align:right;">'+addCommas(Math.round(parseInt(Seed.resources['city'+Seed.cities[ii][0]]['rec'+i][0])/3600))+'</td>';
     	}
		return rec; 
    },
    paintTroops: function(){
    	var troops = "";
    	var units = 16;
    	if (unsafeWindow.unitstats.unt17) units=17;
    	for (var i=1;i<=units;i++){
    		var total= 0;
    		troops+='<TR><TD><B>'+unsafeWindow.unitnamedesctranslated['unt'+i][0]+'</b></td>';
    		for (var ii=0;ii<Seed.cities.length;ii++) total+= parseInt(Seed.units['city'+Seed.cities[ii][0]]['unt'+i]);
    		troops+='<TD style="text-align:right;background: #ffc">'+addCommas(total)+'</td>';
    		for (var ii=0;ii<Seed.cities.length;ii++) troops+='<TD style="text-align:right;">'+ addCommas(parseInt(Seed.units['city'+Seed.cities[ii][0]]['unt'+i]))+'</td>'; 
    		troops+='</tr>';	
    	}
    	return troops;
    },
    getFoodUsage: function(ii){
    	var production = getResourceProduction (Seed.cities[ii][0]);
     	var used = parseInt(Seed.resources["city" + Seed.cities[ii][0]]['rec1'][3]);
      //var used = parseInt(Seed.resourceproduction["city" + Seed.cities[ii][0]]['rec1'][3]);
     	var usage = [production[1],used,(production[1]-parseInt(used))];  // upkeep???
     	return usage;
      //return used;
    },
    getTotalTransporting: function(type){
    	var resource = 0;
    	var what = {1:"food",2:"wood",3:"stone",4:"iron"};
    	if (type == "gold") var hover = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png> 0 marching';
    	else var hover = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+what[type]+'_50.jpg?6545?6545> 0 marching';
    	for (var i=0;i<Seed.cities.length;i++){
    		for (k in Seed.queue_atkp['city'+Seed.cities[i][0]]){
    			transport = Seed.queue_atkp['city'+Seed.cities[i][0]];
    			if (transport[k].marchType==1 && transport[k].marchStatus!=8) {
    			 	if (type == "gold") {
    			 		resource += parseInt(transport[k]['gold']);
    			 		hover = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png> ' + addCommas(resource) + ' marching';
    			 	} else {
    			 		resource +=  parseInt(transport[k]['resource'+type]);
    			 		hover = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+what[type]+'_50.jpg?6545?6545> ' + addCommas(resource) + ' marching';
    			 	}   		 	
    			}
    		}
    	}
    	return hover;
    },
    show: function(){
        OverviewTabActive = true;
    },
    hide: function(){
       OverviewTabActive = false;
    },
    onUnload: function(){
    },
}


/*********************************** Players TAB ***********************************/

function officerId2String (oid){
	if (oid==null) return '';
	else if (oid==3) return unsafeWindow.allianceOfficerTypeMapping[3];
	else if (oid==2) return unsafeWindow.allianceOfficerTypeMapping[2];
	else if (oid==1) return unsafeWindow.allianceOfficerTypeMapping[1];
	else if (oid==4) return unsafeWindow.allianceOfficerTypeMapping[4];
	return '';
}

Tabs.AllianceList = {
    tabOrder : 2,
    type: 'Tools',
    tabLabel : unsafeWindow.g_js_strings.commonstr.player,
    myDiv : null,
    dat : [],
    clickedAlly:false,
    lastLogin:0,
    warStatus:0,
    CityFrom:null,
  
	init : function (div){
		var t = Tabs.AllianceList;
		t.myDiv = div;
		unsafeWindow.PTgetMembers = t.eventGetMembers;
		unsafeWindow.PTPaintMembers = t.GetDataForMap;
		unsafeWindow.PTpd = t.clickedPlayerDetail;
		unsafeWindow.PTpl = t.clickedPlayerLeaderboard;
		unsafeWindow.PTpl2 = t.clickedPlayerLeaderboard2;
		unsafeWindow.PTpFilter = t.FilterPlayer;
		unsafeWindow.PTalClickPrev = t.eventListPrev;
		unsafeWindow.PTalClickNext = t.eventListNext;
		unsafeWindow.PCplo = t.clickedPlayerGetLastLogin;
		unsafeWindow.PTPlayClick = t.clickedPlayerInAll;
		Lastlogin=0;
		t.show();
	},

	fetchPlayerCourt : function (uid, notify){
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.pid = uid;
		 
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt) {notify (rslt);},
			onFailure: function (rslt) {notify (rslt);},
		});
	},
 
	hide : function (){},

  	show : function (){
    	var t = Tabs.AllianceList;
    	if (t.state == null){
      		if (getMyAlliance()[0] == 0) {
        		t.myDiv.innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.membersInfo.youmustbelong+'</center>';
        		t.state = 1;
        		return;
      		}
      		var m = '<DIV class=ptentry><TABLE width=100% cellpadding=0>';
			m+='<TR><TD class=xtab align=right></td><TD class=xtab>'+unsafeWindow.g_js_strings.modal_fow_leaderboard.searchuser+': &nbsp; </td>';
			m+=' <TD width=80% class=xtab><INPUT id=allPlayName size=20 type=text/> &nbsp;'; 
			m+='<INPUT id=playSubmit type=submit class=pbButton value="'+unsafeWindow.g_js_strings.modal_fow_leaderboard.finduser+'" /> &nbsp; <INPUT id=ffbuidsubmit type=submit class=pbButton value="UID" /></td>\
			<TD class="xtab ptErrText"><SPAN id=ptplayErr></span></td></tr>\
			<TR><TD class=xtab></td><TD class=xtab>'+unsafeWindow.g_js_strings.setDiplomacyWindow.srchalli+': &nbsp;</td>\
			<TD class=xtab><INPUT id=allAllName type=text /> &nbsp; <INPUT id=allSubmit type=submit class=pbButton value="'+unsafeWindow.g_js_strings.modal_fow_leaderboard.findalli+'" /></td>\
			<TD class="xtab ptErrText"><SPAN id=ptallErr></span></td></tr>\
			<TR><TD class=xtab><INPUT align=left id=allListSubmit type=submit class=pbButton value="'+unsafeWindow.g_js_strings.commonstr.alliances+'" /></td>\
			<TD class=xtab><INPUT align=right id=idMyAllSubmit type=submit class=pbButton value="'+ getMyAlliance()[1] +'"/>\
			<TD><INPUT id=pbShowFriendlies type=CHECKBOX>Show Friendlys &nbsp;<INPUT id=pbShowHostiles type=CHECKBOX>Show Hostiles</td>\
			 <TD class=xtab></td><TD class=xtab><span align=right <b>'+unsafeWindow.g_js_strings.attack_generateincoming.estimatedarrival+': </b></span>\
			<div><select id="idFindETASelect">\
			<option value="0,0" > -- Select -- </option>\
			<option value="0,180" >'+unsafeWindow.unitcost["unt1"][0]+'</option>\
			<option value="0,200" > '+unsafeWindow.unitcost["unt2"][0]+' </option>\
			<option value="0,3000" > '+unsafeWindow.unitcost["unt3"][0]+' </option>\
			<option value="0,300" > '+unsafeWindow.unitcost["unt4"][0]+' </option>\
			<option value="0,275" > '+unsafeWindow.unitcost["unt5"][0]+' </option>\
			<option value="0,250" > '+unsafeWindow.unitcost["unt6"][0]+' </option>\
			<option value="1,1000" > '+unsafeWindow.unitcost["unt7"][0]+' </option>\
			<option value="1,750" > '+unsafeWindow.unitcost["unt8"][0]+' </option>\
			<option value="1,150" > '+unsafeWindow.unitcost["unt9"][0]+' </option>\
			<option value="1,100" > '+unsafeWindow.unitcost["unt10"][0]+' </option>\
			<option value="1,120" > '+unsafeWindow.unitcost["unt11"][0]+' </option>\
			<option value="1,80" > '+unsafeWindow.unitcost["unt12"][0]+' </option>\
			</select></div></td></tr>\
			<TR><TD colspan=5><DIV id=pbFriendlyDivs style="max-width:725px; white-space:pre-wrap"></div></td>\
			<TR><TD colspan=5><DIV id=pbHostilesDivs style="max-width:725px; white-space:pre-wrap"></div></td>\
			</table><span style="vertical-align:middle;" id=altInput></span></div><SPAN id=allListOut></span>';
			t.myDiv.innerHTML = m;
			document.getElementById('allPlayName').addEventListener ('keypress', function(e) {if ( e.which == 13)  document.getElementById('playSubmit').click();}, false);
			document.getElementById('allAllName').addEventListener ('keypress', function(e) {if ( e.which == 13)  document.getElementById('allSubmit').click();}, false);
			document.getElementById('pbShowFriendlies').addEventListener ('change',function(){
				if (this.checked)t.paintFriendlyDiv();
				 else document.getElementById('pbFriendlyDivs').innerHTML = '';
			});
		    document.getElementById('pbShowHostiles').addEventListener ('change',function(){
		        if (this.checked)t.paintHostilesDiv();
		        else document.getElementById('pbHostilesDivs').innerHTML = '';      
		    });
			document.getElementById('allSubmit').addEventListener ('click', t.eventSubmit, false);
			document.getElementById('playSubmit').addEventListener ('click', t.eventPlayerSubmit, false);
			document.getElementById('ffbuidsubmit').addEventListener ('click', t.eventPlayerUIDSubmit, false);
			document.getElementById('allAllName').addEventListener ('focus', function (){document.getElementById('ptallErr').innerHTML='';}, false);
			document.getElementById('allPlayName').addEventListener ('focus', function (){document.getElementById('ptplayErr').innerHTML='';}, false);
			document.getElementById('allListSubmit').addEventListener ('click', t.eventListSubmit, false);
			document.getElementById('idMyAllSubmit').addEventListener ('click', t.showMyAlliance, false);
			document.getElementById('idFindETASelect').addEventListener ('click', t.handleEtaSelect, false);
			document.getElementById('idFindETASelect').disabled = true;
			t.ModelCity=Cities.cities[0];
			t.curPage = 0;
			t.MaxPage = -1;
			t.state = 1;
    	}
  	},
  	paintFriendlyDiv : function () {
    	var t = Tabs.AllianceList;
    	var mess = ' ----- Friendlys ----- <BR>';
	    for (k in Seed.allianceDiplomacies.friendly) mess += '<INPUT id=pbFriendly_'+k+' type=submit class=pbButton value="'+Seed.allianceDiplomacies.friendly[k].allianceName+'">&nbsp;';
	    document.getElementById('pbFriendlyDivs').innerHTML = mess;
	    for (q in Seed.allianceDiplomacies.friendly) document.getElementById('pbFriendly_'+q).addEventListener('click', function(){unsafeWindow.PTgetMembers(this.id.substr(12))});    
  	},
	paintHostilesDiv : function () {
		var t = Tabs.AllianceList;
		var mess = ' ----- Hostiles ----- <BR>';
		for (k in Seed.allianceDiplomacies.hostile) mess += '<INPUT id=pbHostile_'+k+' type=submit class=pbButton value="'+Seed.allianceDiplomacies.hostile[k].allianceName+'">&nbsp;'; //		
		document.getElementById('pbHostilesDivs').innerHTML = mess;
		for (q in Seed.allianceDiplomacies.hostile) document.getElementById('pbHostile_'+q).addEventListener('click', function(){unsafeWindow.PTgetMembers(this.id.substr(11))});
	},
  	pName : '',
	eventPlayerSubmit : function (){
		var t = Tabs.AllianceList;
		document.getElementById('ptplayErr').innerHTML='';
		var name = document.getElementById('allPlayName').value;
		name = name.replace(/\'/g,"_");
		t.pName = name;
		if (name.length < 3){
		  document.getElementById('ptplayErr').innerHTML = unsafeWindow.g_js_strings.getAllianceSearchResults.entryatleast3;
		  return;
		}
		document.getElementById('altInput').innerHTML = '';
		document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
		t.fetchPlayerList (name, t.eventGotPlayerList);
	},
	eventGotPlayerList : function (rslt){
		var t = Tabs.AllianceList;
		if (!rslt.ok){
		  document.getElementById('allListOut').innerHTML = rslt.errorMsg;
		  return;
		}
		t.playerList = rslt.matchedUsers;
		var uList = [];
		for (k in rslt.matchedUsers) uList.push (rslt.matchedUsers[k].userId);     
		t.fetchPlayerStatus (uList, function(r){t.eventGotPlayerOnlineList(r)});    
	},    
    eventGotPlayerOnlineList : function (rslt){
		var t = Tabs.AllianceList;
		if (!rslt.ok){
		  document.getElementById('allListOut').innerHTML = rslt.errorMsg;
		  return;
		}
		var m = '<DIV class=pbStat>'+unsafeWindow.g_js_strings.recommendSelectedFriends.playersrch+': <B>"'+ t.pName +'"</b></div>\
		  <DIV style="height:575px; max-height:575px; overflow-y:auto">\
		  <TABLE class=pbTab cellspacing=0><TR style="font-weight:bold"><TD width=150px>'+unsafeWindow.g_js_strings.commonstr.nametx+'</td>\
		  <TD align=right width=50px>UID</td><TD align=right width=100px>'+unsafeWindow.g_js_strings.commonstr.might+'</td><TD align=right width=75px>'+unsafeWindow.g_js_strings.commonstr.online+'</td><TD align=center width=100px>Facebook</td><TD align=center width=100px>Delete reports</td><TD width=125px align=center>'+unsafeWindow.g_js_strings.commonstr.search+' </td></tr>';
		var row=0;
		var cl='';
		for (k in t.playerList){
		  var u = t.playerList[k];
		  if (++row % 2) cl = 'class=ptOddrow ';
		  else cl = '';
		  var what = ((CheckFilter(u.userId))?"":'<SPAN onclick="PTpFilter('+u.userId+',\''+u.name+'\')"><A>Add to list</a></span>'); 
		  m += '<TR '+ cl +'valign=top><TD>'+ u.genderAndName +'</td><TD><A target="_tab" href="http://kocmon.com/'+getServerId()+'/players/'+ u.userId +'">' + u.userId + '</a></td><TD align=right>'+ addCommasInt(u.might) +'</td>\
		      <TD align=right>'+ (rslt.data[u.userId]?"&nbsp;<SPAN class=boldDarkRed>"+unsafeWindow.g_js_strings.commonstr.online+"</span>":"") +'</td>\
		      <TD align=center><A target="_tab" href="http://www.facebook.com/profile.php?id='+ u.fbuid +'">'+unsafeWindow.g_js_strings.commonstr.profile+'</a></td>\
		      <TD align=center id=Search_'+u.userId+'>'+what+'</td>\
		      <TD align=center><SPAN onclick="PTpl2(this,'+ u.userId+','+rslt.data[u.userId]+')"><A>'+unsafeWindow.g_js_strings.modaltitles.leaderboard+'</a></span></td></tr>';
				//<SPAN onclick="PTpd(this, '+ u.userId +')"><A>'+unsafeWindow.g_js_strings.modaltitles.memberdetails+'</a> &nbsp; <BR></span>      <SPAN onclick="PCplo(this, \''+ u.userId +'\')"><A>'+unsafeWindow.g_js_strings.modal_messages_viewreports_view.lastlogin+'</a></span>
		}
		m += '</table></div>';
		document.getElementById('allListOut').innerHTML = m;
	},
	FilterPlayer: function(uid,name){
		var t = Tabs.AllianceList;
		Options.PlayerFilter.push({uid:uid,name:name});
		document.getElementById('Search_'+uid).innerHTML ="";
		saveOptions();
	},
  	asName : '', 
    eventPlayerUIDSubmit : function (){
		var t = Tabs.AllianceList;
		document.getElementById('ptplayErr').innerHTML='';
		var uid = document.getElementById('allPlayName').value;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.uid = uid;
		 
		AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
				onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				if (rslt.ok) test = rslt.userInfo[0].name;
				else document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.barbarian.erroroccured+'</center>';
			},
			onFailure: function (rslt) {
			   	document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.errorcode.err_602+'</center>';
				return;
			},
		});
		t.pName = t.asName;
		document.getElementById('altInput').innerHTML = '';
		document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
		setTimeout(t.fetchPlayerList,500, test, t.eventGotPlayerList);
  	},
	clickedPlayerDetail : function (span, uid){
		var t = Tabs.AllianceList;
		span.onclick = '';
		span.innerHTML = unsafeWindow.g_js_strings.commonstr.search +': '+ unsafeWindow.g_js_strings.modaltitles.memberdetails + " ...";
		t.fetchPlayerInfo (uid, function (r) {t.gotPlayerDetail(r, span)});
	},
	clickedPlayerLeaderboard : function (span, uid){
		var t = Tabs.AllianceList;
		span.onclick = '';
		span.innerHTML = unsafeWindow.g_js_strings.commonstr.search +': '+ unsafeWindow.g_js_strings.modaltitles.leaderboard + " ...";
		t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard(r, span)});
	},
	clickedPlayerLeaderboard2 : function (span, uid,status){
		var t = Tabs.AllianceList;
		span.onclick = '';
		span.innerHTML = unsafeWindow.g_js_strings.commonstr.search +': '+ unsafeWindow.g_js_strings.modaltitles.leaderboard + " ...";
		t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard2(r, span,uid,status)});
	},
	clickedPlayerGetLastLogin : function (span, uid){
		var t = Tabs.AllianceList;
		span.onclick = '';
		span.innerHTML = unsafeWindow.g_js_strings.commonstr.search +': '+ unsafeWindow.g_js_strings.modal_messages_viewreports_view.lastlogin + " ...";
		t.fetchPlayerLastLogin (uid, function (r) {t.gotPlayerLastLogin(r, span)});
	},
	gotPlayerLeaderboard2 : function (rslt,span,uid,status){
		var t = Tabs.AllianceList;
		var prestige="";
		if (!rslt.ok){
		  span.innerHTML = rslt.errorMsg;
		  return;
		}
		t.dat = [];
		var myA = getMyAlliance ();
		if (rslt.totalResults == 0){
		  t.fetchPlayerLastLogin (uid, function (r) {t.displayPlayer("",r)});
		  return;
		}
		var p = rslt.results[0];
	    if ( myA[0] == p.allianceId) t.friendEta = true;
	    else t.friendEta = false;
	    for (var c=0; c<p.cities.length; c++){
			if (p.cities[c].prestigeType ==0) prestige = "";
			if (p.cities[c].prestigeType ==1) prestige = "Druid";
			if (p.cities[c].prestigeType ==2) prestige = "Fey";
			if (p.cities[c].prestigeType ==3) prestige = "Briton";
			t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
	       	parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, status,0,p.userId,prestige,p.userId,p.cities[c].tileProvinceId,p.cities[c].dateCreated,p.cities[c].desertionBuffExpire,p.cities[c].prestigeBuffExpire,p.cities[c].blessing,p.cities[c].prestigeLevel,p.cities[c].cityStatus]);
	    }
	    t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
	    t.ModelCity=Cities.cities[0];
	    t.setEta();
	    t.fetchPlayerLastLogin (uid, function (r) {t.displayPlayer(p.allianceName,r)});
	}, 
	gotPlayerLeaderboard : function (rslt, span){
		var t = Tabs.AllianceList;
		if (!rslt.ok){
			span.innerHTML = rslt.errorMsg;
			return;
		}
		if (rslt.totalResults == 0){
			span.innerHTML = '<B>'+unsafeWindow.g_js_strings.commonstr.leaderboard+': </b>'+unsafeWindow.itemlist.i10021.name+'?<BR>';
			return;
		}
		var p = rslt.results[0];
		var an = p.allianceName;
		if (!an || an=='' || p.officerType==4) an = 'none';
		else an += ' ('+ officerId2String(p.officerType) +')';
		pStr = JSON2.stringify(p);
		m = '<TABLE cellspacing=0 class=pbTab><TR><TD><B>'+unsafeWindow.g_js_strings.commonstr.leaderboard+': </b></td><TD colspan=2>'+unsafeWindow.g_js_strings.commonstr.might +': '+ p.might  +' &nbsp; '+unsafeWindow.g_js_strings.commonstr.alliance+': '+ an +'</td></tr>'; 
		for (var i=0; i<p.cities.length; i++){
			var c = p.cities[i];
			var created = '';
			if (c.dateCreated && c.dateCreated.substr(0,2)=='20') created = ' &nbsp; created: ' + c.dateCreated.substr(0,10);
			m += '<TR><TD align=right><B>City #'+ (i+1) +':</b></td><TD> &nbsp; '+ c.cityName 
			m += ' (<a onclick="pbGotoMap ('+ c.xCoord +',' +c.yCoord+ ')">'+ c.xCoord +','+ c.yCoord +'</a>)</td><TD width=75%> &nbsp; level: ';
			m += c.tileLevel +' &nbsp; status: '+ cityStatusString (c.cityStatus) + created +'</td></tr>';
		}  
		span.innerHTML = m + '</table>';
	},
	gotPlayerDetail : function (rslt, span){
		var t = Tabs.AllianceList;
		if (!rslt.ok){
		  span.innerHTML = rslt.errorMsg;
		  return;
		}
		var u = rslt.userInfo[0];
		var a = 'None';
		if (u.allianceName) a = u.allianceName +' ('+ getDiplomacy(u.allianceId) + ')';
		var m = '<DIV style="max-width:550x; width:550px; overflow-y:auto"><TABLE cellspacing=0 class=pbTab><TR><TD><B>Details:</b> &nbsp; </td><TD>'+unsafeWindow.g_js_strings.commonstr.alliance+': '+ a +' &nbsp; '+unsafeWindow.g_js_strings.commonstr.cities+': ';
		m+= u.cities +' &nbsp; '+unsafeWindow.g_js_strings.commonstr.population+': '+ u.population +'</td></tr><TR><TD></td><TD></div>'+unsafeWindow.g_js_strings.commonstr.province+': ';
		var pids = u.provinceIds.split (',');
		var p = [];
		for (var i=0; i<pids.length; i++) p.push(unsafeWindow.provincenames['p'+pids[i]]);
		span.innerHTML = m + p.join (', ') +'</td></tr></table>';
	},
	eventMyAllianceSubmit : function (){
		var t = Tabs.AllianceList;
		document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
		t.fetchAllianceMemberList (getMyAlliance()[0], null, t.eventGotMemberList);
	},  
    aName : '',
	eventSubmit : function (){
		var t = Tabs.AllianceList;
		document.getElementById('ptallErr').innerHTML='';
		if (t.clickedAlly) t.aName = t.clickedAllyName;
		else t.aName = document.getElementById('allAllName').value;	
		if (t.aName.length < 3){
		  document.getElementById('ptallErr').innerHTML = unsafeWindow.g_js_strings.getAllianceSearchResults.entryatleast3;
		  return;
		}
		var myA = getMyAlliance ();
		document.getElementById('altInput').innerHTML = '';
		document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
		if (myA[0]!=0 && myA[1].toLowerCase().indexOf(t.aName.toLowerCase())>=0) t.fetchAllianceList (t.aName, myA[0], t.eventGotAllianceList);
		else t.fetchAllianceList (t.aName, null, t.eventGotAllianceList);
	},

	eventListSubmit : function (){
		var t = Tabs.AllianceList;
		var myA = getMyAlliance ();
		document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
		if (myA[0]!=0  ) {
		   t.curPage=1;
		   t.fetchOtherAllianceInfo ( 1, t.eventGotOtherAlliancePage);
		}
		else document.getElementById('allListOut').innerHTML = unsafeWindow.g_js_strings.membersInfo.youmustbelong;
	},

  eventGotAllianceList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    var m = '<DIV class=pbStat>'+unsafeWindow.g_js_strings.commonstr.alliances+'<B>"'+ t.aName +'"</b></div>\
    <TABLE><TR style="font-weight:bold"><TD class=xtab>'+unsafeWindow.g_js_strings.commonstr.alliance+'</td><TD class=xtab>'+unsafeWindow.g_js_strings.commonstr.rank+'</td><TD class=xtab>'+unsafeWindow.g_js_strings.commonstr.members+'</td>\
        <TD align=right class=xtab>'+unsafeWindow.g_js_strings.commonstr.might+'</td><TD class=xtab>'+unsafeWindow.g_js_strings.getAllianceSearchResults.currdiplo+'</td><TD class=xtab>'+unsafeWindow.g_js_strings.commonstr.members+'</td><TD class=xtab>'+unsafeWindow.g_js_strings.commonstr.viewmap+'</td></tr>';
    for (k in rslt.alliancesMatched){
      var all = rslt.alliancesMatched[k];
      var dip = '';
      if (all.relation && all.relation==1)
        dip = unsafeWindow.g_js_strings.commonstr.friendly;
      else if (all.relation && all.relation==2)
        dip = unsafeWindow.g_js_strings.commonstr.hostile;
      m += '<TR><TD class=xtab>'+ all.allianceName +'</td><TD align=right class=xtab>'+ all.ranking +'</td><TD align=right class=xtab>'+ all.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(all.might) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="PTgetMembers('+ all.allianceId +')">'+unsafeWindow.g_js_strings.commonstr.members+'</a></td>\
        <TD class=xtab><a onclick="PTPaintMembers('+ all.allianceId +')">'+unsafeWindow.g_js_strings.commonstr.viewmap+'</a></td></tr>';
    }
    document.getElementById('allListOut').innerHTML = m;
  },


  showMyAlliance : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
    if (myA[0]!=0  ) {
       t.eventGetMembers(myA[0],false);
    }
    else {
       document.getElementById('allListOut').innerHTML = unsafeWindow.g_js_strings.membersInfo.youmustbelong;
    }
  },

  curPage : 0,
  MaxPage : 0,

  eventListNext : function (amt){
    var t = Tabs.AllianceList;
    if( parseInt(amt) >= 9999 )
       t.curPage = t.MaxPage;
    else {
      t.curPage = parseInt(t.curPage) + parseInt(amt);
      if ( t.curPage > t.MaxPage) {
        t.curPage = t.MaxPage;
      }
    }
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  eventListPrev : function (amt){
    var t = Tabs.AllianceList;
    if(amt <= -1)
       t.curPage = 1;
    else {
      t.curPage-=amt;
      if ( t.curPage < 1 ) {
        t.curPage = 1;
      }
    }
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

   eventGotOtherAlliancePage : function (rslt){
    var t = Tabs.AllianceList;

    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }

    //  document.getElementById('idPageNum').value = t.curPage;

    t.MaxPage=rslt.noOfPages;
    //document.getElementById('idMaxPageNum').innerHTML = 'of ' + t.MaxPage;

    var m = '<div style="overflow:auto; height:556px;width:650px;"><TABLE><thead><TR style="font-weight:bold"> \
        <th class=xtab>'+unsafeWindow.g_js_strings.modaltitles.alliance+'</th><th class=xtab>'+unsafeWindow.g_js_strings.commonstr.rank+'</th><th class=xtab>'+unsafeWindow.g_js_strings.commonstr.members+'</th>\
        <th align=right class=xtab>'+unsafeWindow.g_js_strings.commonstr.might+'</th><th class=xtab>'+unsafeWindow.g_js_strings.getAllianceSearchResults.currdiplo+'</th><th class=xtab>'+unsafeWindow.g_js_strings.commonstr.members+'</th><th class=xtab>'+unsafeWindow.g_js_strings.commonstr.viewmap+'</th></tr></thead><tbody>';
    document.getElementById('allListOut').innerHTML = m;

    for (var i=0; i<rslt.otherAlliances.length; i++) {
      var alliance = rslt.otherAlliances[i];
      var dip = '';
      dip = getDiplomacy(alliance.allianceId);

      m += '<TR class="'+ dip + '"><TD class=xtab>' + alliance.name +'</td><TD align=right class=xtab>'+ alliance.ranking +'</td><TD align=right class=xtab>'+ alliance.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(alliance.might) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="PTgetMembers('+ alliance.allianceId +')">'+unsafeWindow.g_js_strings.commonstr.members+'</a></td>\
         <TD class=xtab><a onclick="PTPaintMembers('+ alliance.allianceId +')">'+unsafeWindow.g_js_strings.commonstr.viewmap+'</a></td></tr>';
    }
    m += '</tbody></TABLE><div style="font-weight:bold"; height:20px;width:560px; ><span> <a onclick="PTalClickPrev(-1)"> [|<] </a><a onclick="PTalClickPrev(10)"> [-10] </a><a onclick="PTalClickPrev(5)"> [-5] </a><a onclick="PTalClickPrev(1)"> [<] </a> \
          <a onclick="PTalClickNext(1)"> [>] </a><a onclick="PTalClickNext(5)"> [+5] </a><a onclick="PTalClickNext(10)"> [+10] </a><a onclick="PTalClickNext(9999)"> [>|] </a> </span></div>';
    m += '</div>';
    document.getElementById('allListOut').innerHTML = m;
 },

  showCurrentPage : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();

    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
    if (myA[0]!=0  ) {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }
    else {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }

  },

  eventGotMemberList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    t.memberListRslt = rslt;
    var uList = [];
    for (k in rslt.results)
      uList.push (rslt.results[k].userId);     
    t.fetchPlayerStatus (uList, function(r){t.eventGotMemberOnlineList(r)});    
  },    
    
  eventGotMemberOnlineList : function (rslt){
    var t = Tabs.AllianceList;
    var numInvalid = 0;
    var numPlayers = 0;
    var myA = getMyAlliance ();
    var prestige="";
    t.dat = [];
    for (var i=0; i<t.memberListRslt.results.length; i++){
      p = t.memberListRslt.results[i];
      if (p.userId == 0){
        ++numInvalid;
      } else {
        ++numPlayers;
        if ( myA[0] == p.allianceId)
           t.friendEta = true;
        else
           t.friendEta = false;
        for (var c=0; c<p.cities.length; c++){
          if (p.cities[c].prestigeType ==0) prestige = "";
          if (p.cities[c].prestigeType ==1) prestige = "Druid";
          if (p.cities[c].prestigeType ==2) prestige = "Fey";
          if (p.cities[c].prestigeType ==3) prestige = "Briton";
          t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
               parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, rslt.data[p.userId]?1:0,'--',p.userId,prestige,p.userId,p.cities[c].tileProvinceId,p.cities[c].dateCreated,p.cities[c].desertionBuffExpire,p.cities[c].prestigeBuffExpire,p.cities[c].blessing,p.cities[c].prestigeLevel,p.cities[c].cityStatus]);
        }
      }
    }
    t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
    t.ModelCity=Cities.cities[0];
    t.setEta();
    t.displayMembers (t.memberListRslt.allianceName, numPlayers);
  },

  // sort and display
  reDisp : function (){
    var t = Tabs.AllianceList;
    function sortFunc (a, b){
      var t = Tabs.AllianceList;
      if (typeof(a[t.sortColNum]) == 'number'){
        if (t.sortDir > 0)
          return a[t.sortColNum] - b[t.sortColNum];
        else
          return b[t.sortColNum] - a[t.sortColNum];
      } else if (typeof(a[t.sortColNum]) == 'boolean'){
// TODO !!        
return 0;        
      } else {
        if (t.sortDir > 0)
          return a[t.sortColNum].localeCompare(b[t.sortColNum]);
        else
          return b[t.sortColNum].localeCompare(a[t.sortColNum]);
      }
    }
    t.dat.sort (sortFunc);
    var m = '';
    var cityName= "";
    for (var i=0; i<t.dat.length; i++){
      cityName = t.dat[i][5].toString() + t.dat[i][6].toString();
      var status = '<img src=""/>';
      if (t.dat[i][9] ==1) status = '<img src=""/>';      

      m += '<TR style="max-height:30px"><TD class=xxtab>'+ status + '<SPAN onclick="PTPlayClick(this, \''+ t.dat[i][13] +'\',\''+ t.dat[i][9] +'\')"><A>'+ t.dat[i][0] +'</a></span></td><TD align=right class=xxtab>'+ addCommasInt(t.dat[i][1]);
      m +='</td><TD align=center class=xxtab>'+ t.dat[i][12] +'</td><TD class=xxtab>'+ officerId2String(t.dat[i][2]);                      
      m +='</td><TD class=xxtab><INPUT id=ScoutCheckbox_'+cityName+' type=checkbox unchecked=true></td><TD class=xxtab><a class=hasTooltip>'+ t.dat[i][7] +'<SPAN>'+t.makeToolTip(i)+'</span></td><TD align=right class=xxtab>'+ t.dat[i][4];
      m +='</td><TD align=center class=xxtab><DIV onclick="pbGotoMap('+ t.dat[i][5] +','+ t.dat[i][6] +')"><A>'+ t.dat[i][5] +','+ t.dat[i][6] +'</a></div></td>';
      m +='<TD align=right class=xxtab style="padding-right:20px;">'+ t.dat[i][8].toFixed(2) +'</td>'
      m +='</td><TD  nowrap class=xxtab>'+ (t.dat[i][10]?'<SPAN>'+ (t.dat[i][10]>0?timestr(t.dat[i][10],1):'--') +'</span>':'<SPAN>--</span>') +'<td class=xxtab><SPAN onclick="PCplo(this, \''+ t.dat[i][11] +'\')"><A>Login</a></span></td>';
      //if (t.dat[i][14]!=undefined && t.dat[i][14]!='0000-00-00 00:00:00') m +='<TD>'+t.dat[i][14]+'</td>';
      //m +='<TD><a class=hasTooltip>Info<SPAN>'+t.makeToolTip()+'</span></a></td>';
      m +='</tr>';

    }
    var tbody = document.getElementById('allBody');
    tbody.style.maxHeight = '';
    tbody.innerHTML = m;


    if (parseInt(tbody.clientHeight) > 470){
      tbody.style.height = '470px';
      tbody.style.maxHeight = '470px';
    }
  },

  makeToolTip: function(i){
  	var t = Tabs.AllianceList;
  	var msg = '<TABLE class=pbTab><TR><TD>Province</td><TD>' + unsafeWindow.provincenames['p'+ t.dat[i][14]] + '</td></tr>';
  	msg += '<TR><TD>Date created</td><TD>' + t.dat[i][15] + '</td></tr>';
  	msg += '<TR><TD>Desertion Buff Exp.</td><TD>' + t.dat[i][16] + '</td></tr>';
  	if (t.dat[i][19] > 0) {
  		var blessing =  t.dat[i][18].split(',');
  		msg += '<TR><TD>Prestige Buff Exp.</td><TD>' + t.dat[i][17] + '</td></tr>';
  		msg += '<TR><TD>Prestige Level</td><TD>' + t.dat[i][19] + '</td></tr>';
  		for (var y=1;y<=t.dat[i][19];y++) {
  			msg += '<TR><TD>Blessing '+y+'</td><TD>' + unsafeWindow.g_js_strings.blessingSystem['blessing_name_'+blessing[y-1]] + '</td></tr>';
  			msg += '<TR><TD></td><TD>'+unsafeWindow.g_js_strings.blessingSystem['blessing_description_'+blessing[y-1]]+'</td></tr>';
  		}  		
  	}
  	msg += '<TR><TD>City Status</td><TD>' + t.dat[i][20] + '</td></tr>';
  	msg += '</table>'
  	return msg;	
  },

  clickedPlayerInAll : function (span,uid,status){
    var t = Tabs.AllianceList;
    t.clickedPlayerLeaderboard2(span,uid,status);
  },

  setDistances : function (x, y){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++) t.dat[i][8] = distance (x, y, t.dat[i][5], t.dat[i][6]);
  },

  friendEta:false,

  setEta : function (){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++) {
      if (t.dat[i][8]) {
        var eta = t.estETA(parseFloat(t.dat[i][8]));
        if (t.friendEta)
           t.dat[i][10] = eta.friendETA;
        else
           t.dat[i][10] = eta.ETA;
      }
    }
  },



  handleEtaSelect : function (){
    var t = Tabs.AllianceList;
    t.setEta();
    t.reDisp();
  },

  sortColNum : 8,
  sortDir : 1,

  displayMembers : function (allName, numPlayers){
    var t = Tabs.AllianceList;
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      document.getElementById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
    unsafeWindow.PTalClickSort = alClickSort;
    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
      <DIV class=pbStat ><TABLE id=tabAllMembers cellpadding=0  width=100%><TR font-weight:bold"><TD class=xtab> &nbsp; '+ allName +'</td>\
        <TD class=xtab width=80% align=center>'+unsafeWindow.g_js_strings.commonstr.distance+ unsafeWindow.g_js_strings.commonstr.from+' <SPAN id=distFrom>'+ Cities.cities[0].name +' ('+ Cities.cities[0].x +','+ Cities.cities[0].y +')</span></td><TD class=xtab align=right>'+ numPlayers + unsafeWindow.g_js_strings.commonstr.members+'&nbsp; </td></tr></table></div>\
       <div style="max-height:500px; height:500px; overflow-y:auto;"><TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD style="overflow-y:auto;">\
      <TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+unsafeWindow.g_js_strings.commonstr.player+'</div></a></td>\
         <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Might</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>Faction</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Rank</a></div></td>\
        <TD id=clickCol9 class=clickable align=center><DIV><INPUT id=ToggleScoutCheckbox type=checkbox unchecked=true></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>City Name</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>Lvl</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>Coords</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>Dist.</a></div></td>\
        <TD id=clickCol10 onclick="PTalClickSort(this)" class=clickable><A><DIV>Eta</a></div></td>\
        <TD class=clickable><A><DIV>Login</a></div></td></tr></thead>\
      <TBODY id=allBody style="background-color:#ffffff;"></tbody></table></div>';
      
    document.getElementById('allListOut').innerHTML = m; //style="top:670px; left:0px; position:absolute;

    m = '<HR><TABLE width=100% cellpaddding=0><TR>';
    m+= '<TD class=xtab>Show distance from: &nbsp; X: <INPUT size=2 type=text id=plyrX /> Y: <INPUT size=2 type=text id=plyrY /> &nbsp; Or, choose city: <span id=dmcoords></span></td></tr>';
    m+= '<TR><TD class=xtab><DIV id=PaintScout></div></td></tr></table>';
    document.getElementById('altInput').innerHTML = m;

        
    document.getElementById('clickCol'+t.sortColNum).className = 'clickable clickableSel';
    document.getElementById('ToggleScoutCheckbox').addEventListener ('change', t.doSelectall,false);

    t.reDisp();
    //CdispCityPicker (id, span, dispName, notify, selbut, disable_list)
    t.CityFrom = new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0);
    document.getElementById('plyrX').value = t.CityFrom.city.x;
	document.getElementById('plyrY').value = t.CityFrom.city.y;
    
    document.getElementById('plyrY').addEventListener ('change', function(){t.eventCoords(null,document.getElementById('plyrX').value,document.getElementById('plyrY').value);},false); 
    document.getElementById('plyrX').addEventListener ('change', function(){t.eventCoords(null,document.getElementById('plyrX').value,document.getElementById('plyrY').value);},false); 
    document.getElementById('idFindETASelect').disabled = false;
    t.eventCoords(t.CityFrom.city.id,t.CityFrom.city.x,t.CityFrom.city.y);
  },
  
  displayPlayer : function (allName,rslt){
    var t = Tabs.AllianceList;
    var status = "";
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      document.getElementById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
    unsafeWindow.PTalClickSort = alClickSort;

    switch (parseInt(rslt.playerInfo.warStatus)) {
        case 1: status = unsafeWindow.g_js_strings.commonstr.normal;break;
        case 2: status = unsafeWindow.g_js_strings.MapObject.begprotect;break;
        case 3: status = unsafeWindow.g_js_strings.commonstr.truce;break;
        case 4: status = unsafeWindow.g_js_strings.commonstr.vacation;break;
        default: status = unsafeWindow.g_js_strings.commonstr.normal
    }

    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
             <DIV id=playerInfo></div><DIV id=TRStats></div>\
      <div style="max-height:470px; height:470px; overflow-y:auto;"><TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD style="overflow-y:hidden;">\
      <TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>Player</div></a></td>\
        <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Might</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>Faction</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Rank</a></div></td>\
        <TD id=clickCol9 class=clickable align=center><DIV><INPUT id=ToggleScoutCheckbox type=checkbox unchecked=true></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>City Name</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>Lvl</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>Coords</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>Distance</a></div></td>\
        <TD id=clickCol10 onclick="PTalClickSort(this)" class=clickable><A><DIV>Eta</a></div></td>\
    <TD class=clickable><A><DIV>Login</a></div></td>\
    <TD class=clickable><A><DIV>Prestige Buff Exp.</a></div></td></tr></thead>\
      <TBODY id=allBody style="background-color:#ffffff;"></tbody></table></div>\
      <DIV  width:100%; style="top:670px; left:0px; position:absolute; background-color:#ffffff; border-top:1px solid; margin-top:8px; color:#700; font-weight:bold;">';
    document.getElementById('allListOut').innerHTML = m;  //style="top:670px; left:0px; position:absolute;
    
    m = '<HR><TABLE width=100% cellpaddding=0><TR align=left>';
    m+= '<TD class=xtab>Show distance from: &nbsp; X: <INPUT size=2 type=text id=plyrX /> Y: <INPUT size=2 type=text id=plyrY /> &nbsp; Or, choose city: <span id=dmcoords></span></td></tr>';
    m+= '<TR align=left><TD class=xtab><DIV id=PaintScout></div></td></tr></table>';
    document.getElementById('altInput').innerHTML = m;

    m = '<TABLE><TR><TD class=xtab style="width:75px">Alliance:</td><TD class=xtab style="width:150px"><a onclick="PTgetMembers('+ rslt.playerInfo.allianceId +')">'+rslt.playerInfo.allianceName+'</a></td></tr>';
    m+= '<TR><TD class=xtab>Last Login:</td><TD class=xtab>' + rslt.playerInfo.lastLogin + '</td></tr>';
    m+= '<TR><TD class=xtab>Status:</td><TD class=xtab>' + status + '</td>';
    now = unixTime();
    if (rslt.playerInfo.warStatus > 1 && ((rslt.playerInfo.truceExpireUnixTime - now)>0)) m+= '<TD class=xtab>Expires: ' + rslt.playerInfo.truceExpireTimestamp + ' (' + timestr(rslt.playerInfo.truceExpireUnixTime - now) +')</td></tr>';
    if (t.dat.length ==0) m+= '<TR><TD class=xtab><B>MISTED?</b></td><TD class=xtab>Expires: ' + rslt.playerInfo.fogExpireTimestamp +'</td></tr>';
    m+= '<TR><TD class=xtab>Glory:</td><TD class=xtab><DIV id=PaintGlory></div></td></tr><TR><TD class=xtab>Max Glory:</td><TD class=xtab><DIV id=PaintMaxGlory></div></td></tr><TR><TD class=xtab>Provinces:</td><TD class=xtab><DIV id=PaintProvinces></div></td></tr>';

    m +='</table><BR>Compare Throne Room : <INPUT id=CompareTR type=submit class=pbButton value="Compare"><INPUT id=CalcTR type=submit class=pbButton value="Calculate"><BR><BR>';

    document.getElementById('playerInfo').innerHTML = m;
    document.getElementById('ToggleScoutCheckbox').addEventListener ('change', t.doSelectall,false);
    document.getElementById('CompareTR').addEventListener ('click', function (){t.TRStats(rslt.playerInfo.userId,rslt.playerInfo.displayName,"Compare")},false);
    document.getElementById('CalcTR').addEventListener ('click', function (){t.TRStats(rslt.playerInfo.userId,rslt.playerInfo.displayName,"Calc")},false);
    document.getElementById('clickCol'+t.sortColNum).className = 'clickable clickableSel';

    t.PaintGlory(rslt.playerInfo.userId);
    t.fetchPlayerInfo (rslt.playerInfo.userId, function (r) {t.PaintProvinces(r)});
    t.reDisp();
    t.CityFrom = new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0);
    document.getElementById('plyrX').value = t.CityFrom.city.x;
	document.getElementById('plyrY').value = t.CityFrom.city.y;
    document.getElementById('idFindETASelect').disabled = false;
    document.getElementById('plyrY').addEventListener ('change', function(){t.eventCoords(null,document.getElementById('plyrX').value,document.getElementById('plyrY').value);},false); 
    document.getElementById('plyrX').addEventListener ('change', function(){t.eventCoords(null,document.getElementById('plyrX').value,document.getElementById('plyrY').value);},false); 
  	t.eventCoords(t.CityFrom.city.id,t.CityFrom.city.x,t.CityFrom.city.y);
  },

   PaintProvinces: function(r){
   		document.getElementById('PaintProvinces').innerHTML="";
   		var pids = r.userInfo[0].provinceIds.split (',');
		var p = [];
		for (var i=0; i<pids.length; i++) p.push(unsafeWindow.provincenames['p'+pids[i]]);
		document.getElementById('PaintProvinces').innerHTML = p.join (', ');
   },

  PaintGlory: function(uid){
        var t = Tabs.AllianceList;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.userId = uid;
        params.ctrl = 'PlayerProfile';
		params.action = 'get';
		 
        new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
            method: "post",
            parameters: params,
            onSuccess: function (transport) {
              var rslt = eval("(" + transport.responseText + ")");
              if(rslt.ok) {
                document.getElementById('PaintGlory').innerHTML = addCommas(rslt.profile.glory);
                document.getElementById('PaintMaxGlory').innerHTML = addCommas(rslt.profile.maxGlory);
              } else t.PaintGlory(uid);

            },
            onFailure: function () {
            },
        });   
 },



    HisStatEffects: [],
    MyStatEffects: [],

  TRStats : function (uid,name,what){
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
	params.action = 'getEquipped';
	params.playerId = uid;
  	 
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    loading: true,
    onSuccess: function (transport) {
      var rslt = eval("(" + transport.responseText + ")");
        if(rslt.ok){
          for (k in unsafeWindow.cm.thronestats.effects) t.HisStatEffects[k] = 0;
          for (kk=0;kk<=6;kk++){
              y = rslt.items[kk];
              if (y != undefined) {
                for (i=1;i<=5;i++) {
                     id = y["effects"]["slot"+i]["id"];
                   tier = parseInt(y["effects"]["slot"+i]["tier"]);
                   level = y["level"];
                   p = unsafeWindow.cm.thronestats.tiers[id][tier];
                   Current = p.base + ((level * level + level) * p.growth * 0.5);
                   if (i<=parseInt(y["quality"])) t.HisStatEffects[id] += Current;
              }
            }
          }
          for (k in unsafeWindow.cm.thronestats.effects) t.MyStatEffects[k] = 0;
            for (k in unsafeWindow.kocThroneItems){
              y = unsafeWindow.kocThroneItems[k];
              for (i=1;i<=5;i++) {
                id = y["effects"]["slot"+i]["id"];
                tier = parseInt(y["effects"]["slot"+i]["tier"]);
                level = y["level"];
                p = unsafeWindow.cm.thronestats.tiers[id][tier];
                Current = p.base + ((level * level + level) * p.growth * 0.5);
                if (y.isEquipped && i<=y["quality"]) t.MyStatEffects[id] += Current
            }
          }
          if (what == "Compare") t.PaintTRCompare(name);
          if (what == "Calc") t.PaintTRCalc(name);
         } else t.TRStatsCompare();
    },
    onFailure: function () {
       return;
    },
  });           
  },


	TRlineHolder : {
		1:{1:"Attack",2:null},2:{1:1,2:17},3:{1:24,2:29},4:{1:34,2:39},5:{1:44,2:50},6:{1:56,2:61},7:{1:17,2:1},8:{1:29,2:24},9:{1:39,2:34},10:{1:50,2:44},11:{1:61,2:56},
		12:{1:"Defense",2:null},13:{1:2,2:18},14:{1:25,2:30},15:{1:35,2:40},16:{1:45,2:51},17:{1:18,2:2},18:{1:30,2:25},19:{1:40,2:35},20:{1:51,2:45},
		21:{1:"Life",2:null},22:{1:3,2:19},23:{1:26,2:31},24:{1:36,2:41},25:{1:46,2:52},26:{1:19,2:3},27:{1:31,2:26},28:{1:41,2:36},29:{1:52,2:46},
		30:{1:"Combat Speed",2:null},31:{1:4,2:20},32:{1:27,2:32},33:{1:47,2:53},34:{1:57,2:62},35:{1:20,2:4},36:{1:32,2:27},37:{1:53,2:47},38:{1:62,2:57},
		39:{1:"Range",2:null},40:{1:5,2:21},41:{1:37,2:42},42:{1:58,2:63},43:{1:21,2:5},44:{1:42,2:37},45:{1:63,2:58},  
		46:{1:"Load",2:null},47:{1:6,2:22},48:{1:48,2:54},49:{1:59,2:64},50:{1:22,2:6},51:{1:54,2:48},52:{1:64,2:59},
		52:{1:"Accuracy",2:null},53:{1:7,2:23},54:{1:28,2:33},55:{1:38,2:43},56:{1:49,2:55},57:{1:60,2:65},58:{1:23,2:7},59:{1:33,2:28},60:{1:43,2:38},61:{1:55,2:49},62:{1:65,2:60}, 
		63:{1:"Other",2:null},64:{1:8,2:8},65:{1:9,2:9},65:{1:10,2:10},66:{1:11,2:11},67:{1:12,2:12},68:{1:13,2:13},69:{1:14,2:14},70:{1:15,2:15},71:{1:16,2:16},72:{1:66,2:66},73:{1:67,2:67},74:{1:68,2:68},75:{1:69,2:69},76:{1:70,2:70},77:{1:71,2:71},78:{1:72,2:72},79:{1:73,2:73},80:{1:74,2:74},81:{1:75,2:75},82:{1:76,2:76},83:{1:77,2:77},84:{1:78,2:78},85:{1:79,2:79},86:{1:80,2:80},87:{1:81,2:81},88:{1:82,2:82},89:{1:83,2:83},90:{1:84,2:84},91:{1:85,2:85},92:{1:86,2:86},93:{1:87,2:87},94:{1:88,2:88},95:{1:89,2:89},96:{1:90,2:90},97:{1:91,2:91},98:{1:92,2:92},99:{1:93,2:93},100:{1:94,2:94},101:{1:95,2:95},102:{1:96,2:96},
	},

	PaintTRCalc : function (name){
		var t = Tabs.AllianceList;
		m = '<BR><BR><DIV style="max-height:690px; height:690px; overflow-y:scroll;"><TABLE><TD width="35px" class=xtab></td><TD class=xtab><B>' + name + '</b><TD  width="50px"></td><TD class=xtab><B>'+ Seed.player.name+'</b></td>';
		for (z=1;z<=102;z++) {
			var HisContent = "";
			var MyContent = "";
			var His = t.TRlineHolder[z][1];
			var My = t.TRlineHolder[z][2];
			var diff = 0;
			var color = "black";
			if (t.TRlineHolder[z][2] == null) {
			  m+= '<TR><TD>&nbsp</td></tr><TR><TD class=xtab></td><TD class=xtab><B><U>' + t.TRlineHolder[z][1] + '</b></u><TD  width="50px" class=xtab></td><TD class=xtab></td></tr>';
			} else {
				if (t.HisStatEffects[His] != 0) HisContent = t.HisStatEffects[His] + '% ' + unsafeWindow.cm.thronestats["effects"][His]["1"];
				if (t.MyStatEffects[My] != 0) MyContent = t.MyStatEffects[My] + '% ' + unsafeWindow.cm.thronestats["effects"][My]["1"]; 
				if (t.HisStatEffects[His] != 0 && t.MyStatEffects[My] != 0) { 
				if (z < 63) diff = (parseInt(t.HisStatEffects[His]) + parseInt(t.MyStatEffects[My]));
				if (z > 63) diff = ( parseInt(t.MyStatEffects[My]) - parseInt(t.HisStatEffects[His]) );
				if (MyContent.indexOf("Debuff") != -1 && diff > 0) color = "red";
				else if (MyContent.indexOf("Debuff") != -1 && diff < 0) color = "green";
				else if (HisContent.indexOf("Debuff") != -1 && diff > 0) color = "green";
				else if (HisContent.indexOf("Debuff") != -1 && diff < 0) color = "red";
				else if (diff < 0) color = "red";
				else color = "green";
				m+='<TR><TD class=xtab><FONT color='+ color +'><I><B>'+ diff +'</b></i></font></td><TD class=xtab>' + HisContent + '</td><TD class=xtab></td><TD class=xtab>' + MyContent + '</td>';
			  } else if (t.HisStatEffects[His] != 0 || t.MyStatEffects[His] != 0) m+='<TR><TD class=xtab></td><TD class=xtab>' + HisContent + '</td><TD class=xtab></td><TD class=xtab>' + MyContent + '</td>';
			  m+='</tr>'; 
			}
		}
		m +='</table></div>';
		var popMsg = null;
		t.popMsg = new pbPopup('pbMailBody', 0, 0, 550, 750, true, function() {clearTimeout (1000);});
		t.popMsg.centerMe (mainPop.getMainDiv());
		t.popMsg.getMainDiv().innerHTML = m;
		t.popMsg.getTopDiv().innerHTML = '<DIV align=center><B>Throne Room Compare</B></DIV>';
		t.popMsg.show(true);  
	},
	PaintTRCompare : function (name){
    	var t = Tabs.AllianceList;
    	m = '<BR><BR><DIV style="max-height:690px; height:690px; overflow-y:scroll;"><TABLE><TD class=xtab></td><TD class=xtab><B>' + name + '</b><TD></td><TD class=xtab><B>'+ Seed.player.name+'</b></td></tr><TR><TD>&nbsp</td></tr>';
  		for (k=1;k<t.MyStatEffects.length;k++) {
    		var HisContent = "";
    		var MyContent = "";
    		if (t.HisStatEffects[k] != 0) HisContent = t.HisStatEffects[k] + '% ' + unsafeWindow.cm.thronestats["effects"][k]["1"];
    		if (t.MyStatEffects[k] != 0) MyContent = t.MyStatEffects[k] + '% ' + unsafeWindow.cm.thronestats["effects"][k]["1"];
    		if (t.HisStatEffects[k] != 0 || t.MyStatEffects[k] != 0) m+='<TR><TD  width="25px" class=xtab></td><TD class=xtab>' + HisContent + '</td><TD  width="50px" class=xtab></td><TD class=xtab>' + MyContent + '</td></tr>';
  		}
		m +='</table></div>';
		var popMsg = null;
		t.popMsg = new pbPopup('pbMailBody', 0, 0, 550, 750, true, function() {clearTimeout (1000);});
		t.popMsg.centerMe (mainPop.getMainDiv());
		t.popMsg.getMainDiv().innerHTML = m;
		t.popMsg.getTopDiv().innerHTML = '<DIV align=center><B>Throne Room Compare</B></DIV>';
		t.popMsg.show(true);  
  	},
	rallypointlevel: 0,
	MaxScouts : function (city){
	    var t = Tabs.AllianceList;
	    var othertroops=0;
	    var max = 0;
	    var maxsend = 0;
	    t.getRallypoint("city" + city.id);
	    RallypointMax = (t.rallypointlevel * 10000);
	    maxsend = RallypointMax + ((RallypointMax / 100) * unsafeWindow.cm.ThroneController.effectBonus(66));
	    for (i=1;i<=16;i++) othertroops += parseInt(document.getElementById('Unt'+3).value);
	    if (othertroops < maxsend) max = (maxsend - othertroops);
	    if (max > Seed.units["city" + city.id]["unt"+3]) max = Seed.units["city" + city.id]["unt"+3];
	    document.getElementById('numScouts').value = max;
  	},

getRallypoint: function(cityId){
  var t = Tabs.AllianceList;

  for (var o in Seed.buildings[cityId]){
    var buildingType = parseInt(Seed.buildings[cityId][o][0]);
    var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
    if (buildingType == 12) t.rallypointlevel=parseInt(buildingLevel);
   }
 if(t.rallypointlevel == 11) t.rallypointlevel = 15;
 if(t.rallypointlevel == 12) t.rallypointlevel = 20;      
},


  doSelectall : function (){
    var t = Tabs.AllianceList;
    var city = "";
    for (var k=0;k<t.dat.length;k++){
      city = t.dat[k][5].toString() + t.dat[k][6].toString();
      if (document.getElementById('ToggleScoutCheckbox').checked) document.getElementById('ScoutCheckbox_'+city).checked = true;
      else document.getElementById('ScoutCheckbox_'+city).checked = false
    }
  },

  	CheckCityMarches:function(cityID){
  		var Counter=0;
		var now=unixTime();
		if (Seed.queue_atkp['city'+ cityID] != undefined) for (atkp in Seed.queue_atkp['city'+ cityID]) if (Seed.queue_atkp['city'+ cityID][atkp]["marchId"] || Seed.queue_atkp['city'+ cityID][atkp]["returnUnixTime"]>now) Counter++;
		return Counter;
	},

  doAddScout : function (){
    var t = Tabs.AllianceList;
    var count = -1;
    var city="";
    slots = t.CheckCityMarches(t.CityFrom.city.id);
  	rallypointlevel = getRallypoint(t.CityFrom.city.id);
    for (var k=0;k<t.dat.length;k++){ 
      if (t.dat[k][5] != undefined && t.dat[k][6] != undefined){
        var x = t.dat[k][5];
        var y = t.dat[k][6];
        city = t.dat[k][5].toString() + t.dat[k][6].toString();
        var box = 'ScoutCheckbox_'+city;
        if (document.getElementById(box).checked) count++;
        if (document.getElementById(box).checked && (count+1) <= (rallypointlevel-slots))setTimeout(t.doScout,(2000*count), x,y,box);
      }
    }
  },

  doScout : function (x,y,box) {
    var t = Tabs.AllianceList;
    slots = t.CheckCityMarches(t.CityFrom.city.id);
  	rallypointlevel = getRallypoint(t.CityFrom.city.id);
  	if (slots==rallypointlevel) return;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid= t.CityFrom.city.id;
	params.type = 3
	params.kid = 0
	params.xcoord = x;
	params.ycoord = y;
	params.u3 = document.getElementById('numScouts').value;
	params.gold = 0;
	params.r1 = 0;
	params.r2 = 0;
	params.r3 = 0;
	params.r4 = 0;
	params.r5 = 0;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          loading: true,
          onSuccess: function (rslt) {
              var t = Tabs.AllianceList;  
              if (rslt.ok) {
                var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
                var ut = unsafeWindow.unixtime();
                var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
                for(i = 0; i <= unitsarr.length; i++){
                    if(params["u"+i]){
                      unitsarr[i] = params["u"+i];
                    }
                }
                var resources=new Array();
                resources[0] = params.gold;
                for(i=1; i<=4; i++){
                    resources[i] = params["r"+i];
                }
                var currentcityid =  params.cid;
                unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
                unsafeWindow.update_seed(rslt.updateSeed)
                if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                document.getElementById(box).checked = false;        
              } else if (rslt.error_type==0 || rslt.error_type==8) t.doScout(x,y,box);
          }, 
          onFailure: function () {},
    });
  },

  
  eventCoords : function (city, x, y){
    var t = Tabs.AllianceList;
    document.getElementById('PaintScout').innerHTML = 'Scout selected cities from: ' + t.CityFrom.city.name + ' with <INPUT id=numScouts type=text maxlength=7 size=7 value="1"><INPUT id=MaxScout type=submit class=pbButton value=Max> Scout(s) <INPUT id=scoutAllSelected type=submit class=pbButton value=GO>';
    document.getElementById('scoutAllSelected').addEventListener('click', function (){t.doAddScout();});
    document.getElementById('MaxScout').addEventListener('click', function (){t.MaxScouts(city);});
    var m = '';
    if (city != null) {
    	document.getElementById('plyrX').value = city.x;
    	document.getElementById('plyrY').value = city.y;
    	m = city.name +' ('+ city.x +','+ city.y +')';
    } else m = x +','+ y;
    var distFrom = document.getElementById('distFrom');
    if (distFrom) distFrom.innerHTML = m;
    t.ModelCity=city;
    if (city !=null) t.JumpCity(city.name);
    t.setDistances(x,y);
    t.setEta();
    t.reDisp();
  },

  eventGetMembers : function (aid){
    var t = Tabs.AllianceList;
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>'+unsafeWindow.g_js_strings.commonstr.loadingddd+'</center>';
    t.fetchAllianceMemberList (aid, null, t.eventGotMemberList);
  },

  fetchAllianceMemberList : function (allianceId, allianceName, notify) {
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.type = "might";
    params.page = 1;
    params.perPage = 100;
    if (allianceName)
      params.allianceName = allianceName;
    if (allianceId && allianceId != 0)
      params.allianceId = allianceId;
  	 
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  GetDataForMap : function (allianceId) {
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    var Data=[];
    params.perPage = 100;
    params.allianceId = allianceId;
    params.type = "might";
    params.page = 1;
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        var city = '';
        for (var i=0; i<rslt.results.length; i++) {
            if (rslt.results[i]['userId'] !=0){
              player = rslt.results[i]['cities'];
              for (var ii=0; ii<player.length; ii++) 
              Data.push ({X:player[ii]['xCoord'],Y:player[ii]['yCoord']});
        }   
        }
        if (Data != []) t.PaintDataOnMap(Data);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  
  PaintDataOnMap : function(Data){
      var provMapCoordsA = {imgWidth:710, imgHeight:708, mapWidth:670, mapHeight:670, leftMargin:31, topMargin:19};  
      var map = '<DIV id=ptAlliProvMap style="height:'+ provMapCoordsA.imgHeight +'px; width:'+ provMapCoordsA.imgWidth +'px; background-repeat:no-repeat; background-image:url(\''+ URL_PROVINCE_MAP +'\')"></div>';
        
    //alert(Data.toSource());
    //Data = [{X:"700", Y:"700"}, {X:"600", Y:"600"}, {X:"500", Y:"500"},{X:"400", Y:"400"},{X:"300", Y:"300"},{X:"200", Y:"200"},{X:"100", Y:"100"},{X:"0", Y:"0"},{X:"750", Y:"750"}, {X:"650", Y:"650"}, {X:"550", Y:"550"},{X:"450", Y:"450"},{X:"350", Y:"350"},{X:"250", Y:"250"},{X:"150", Y:"150"},{X:"50", Y:"50"}];
              
    document.getElementById('allListOut').innerHTML = map;
    var eMap =  document.getElementById('ptAlliProvMap');
    
    
    
    
    
    for (var cc=0; cc<Seed.cities.length; cc++) {
        var city = Seed.cities;
        var Xplot = parseInt((provMapCoordsA.mapWidth * parseInt(city[cc][2])) / 750);
        var Yplot = parseInt((provMapCoordsA.mapHeight * parseInt(city[cc][3])) / 750);
        var cf = document.createElement ('div');
        cf.style.background = 'black';
        cf.style.opacity = '1.0';
        cf.style.position='relative';
        cf.style.display='block';
        cf.style.width='14px';
        cf.style.height='16px';
        cf.style.border='1px solid #fff';
        cf.style.color = 'white';
        cf.style.textAlign = 'center';
        cf.style.top = (Yplot+provMapCoordsA.topMargin-(cc*16)-8) +'px';      
        cf.style.left = (Xplot+provMapCoordsA.leftMargin-7) +'px';
        cf.innerHTML = (cc+1) +'';
        eMap.appendChild(cf);
        
    }

    for (var i=0;i<Data.length;i++) {
      var x = parseInt(Data[i]['X']);
      var y = parseInt(Data[i]['Y']);
            var xplot = parseInt((provMapCoordsA.mapWidth * x) / 750);
            var yplot = parseInt((provMapCoordsA.mapHeight * y) / 750);
          var ce= document.createElement ('div');
            ce.style.background = 'red';
            ce.style.opacity = '1.0';
            ce.style.position='relative';
            ce.style.display='block';
            ce.style.width='4px';
            ce.style.height='4px';
            ce.style.color = 'white';
            ce.style.textAlign = 'center';
          ce.style.top = (yplot+provMapCoordsA.topMargin -(4*i)-((Seed.cities.length)*18)) +'px';      
          ce.style.left = (xplot+provMapCoordsA.leftMargin -2) +'px';
          //ce.innerHTML = '<span onmouseover="this.innerText='+x+','+y+'" onclick="">A</span>';
          ce.innerHTML = '<DIV onclick="pbGotoMap('+ x +','+ y +')">&nbsp;</div>';
            eMap.appendChild(ce);
       }
       
       
  },
  
  fetchLeaderboard : function (uid, notify) {
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.userId = uid;
    params.type = "might";
    params.page = 1;
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchAllianceList : function (allianceName, myAid, notify) {   // at least 3 chars :)
    var t = Tabs.AllianceList;
    function combineResults (rsltA, rsltM, notify){
      if (!rsltA.ok){
        if (rsltA.msg.indexOf("No alliance found under")!=0 || !rsltM.ok){
          notify (rsltA);
          return;
        }
        rsltA.ok = true;
        rsltA.count = 0;
        rsltA.alliancesMatched = {};
      }
      if (rsltM.ok){
        rsltA.alliancesMatched['a'+rsltM.allianceInfo.allianceId] = {allianceId: rsltM.allianceInfo.allianceId, allianceName: rsltM.allianceInfo.allianceName,
              membersCount: rsltM.allianceInfo.members, relation: null, might: rsltM.allianceInfo.might, ranking: rsltM.allianceInfo.ranking};
        ++rsltA.count;
      }
      notify (rsltA);
    }
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.allianceName = allianceName;
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetSearchResults.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (myAid!=null && myAid>0)
          t.fetchMyAllianceInfo  (function (r){ combineResults (rslt, r, notify)});
        else
          notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchOtherAllianceInfo : function (pageNum, notify){    // as in alliance list, sorted by rank, 10 per page
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.pageNo = pageNum;
    params.cityId = unsafeWindow.currentcityid;
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetOtherInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchMyAllianceInfo : function (notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchPlayerList : function (name, notify){  // at least 3 chars!! 
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.searchName = name;
    params.subType = "ALLIANCE_INVITE";
     
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/searchPlayers.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchPlayerInfo : function (uid, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.uid = uid;

    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  
/***
ajax/getOnline.php:
  (string) ok = true
  (object) data = [object Object]
    (boolean) 4394121 = false
  (undefined) errorMsg: null = null
***/
  fetchPlayerStatus : function (uidArray, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.checkArr = uidArray.join(',');
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  
  fetchPlayerLastLogin : function (uid, notify){
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.pid = uid;
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          notify (rslt);
        },
        onFailure: function (rslt) {
          notify ({errorMsg:'AJAX error'});
        },
      });
    },
    
    gotPlayerLastLogin : function (rslt, span){
        var t = Tabs.AllianceList;
        if (!rslt.ok){
          span.innerHTML = rslt.errorMsg;
          return;
        }
    
        var p = rslt.playerInfo;
        var lastLogin = rslt.playerInfo.lastLogin;
    
        if (lastLogin) {
          m = '<span style="color:black">'+unsafeWindow.g_js_strings.modal_messages_viewreports_view.lastlogin+': '+lastLogin+'</span>';
        } else {
           m = '<span style="color:red">No login date found: '+lastLogin+'</span>';
        }
        span.innerHTML = m + '';
      },

  ModelCity : {},

  estETA : function(dist) { // Need Relief Station Levels to estimate transport, reinf, or reassign times. 
    var t = Tabs.AllianceList;
    var ret={ETA:0,etaStr:'NA',friendETA:0,friendEtaStr:'NA'};    
    var cityID;
    if (dist <= 0) return ret;
    var EtaType = document.getElementById('idFindETASelect');
    var baseSpeedSel = EtaType.options[EtaType.selectedIndex].value;
    var m = baseSpeedSel.split(',');
    var horse = 0;
    var baseSpeed = 0;
    if(m) {
      horse = parseInt(m[0]);
      baseSpeed = parseInt(m[1]);
    }
    if (baseSpeed == 0) return ret;
    var mmLvl = parseInt(Seed.tech.tch11);//Magical Mapping
    var Speed = 0;
    if (horse){
   //HorsesSiegeSpeed = Base * (1 + MM/10) * (1 + AH/20) 
      var hsLvl = parseInt(Seed.tech.tch12);//Alloy Horse Shoes
      Speed = baseSpeed * (1 + mmLvl/10.0) * (1 + hsLvl/20.0);
    }
    else {
    //FootSpeed = Base * (1 + MM/10)
      Speed = baseSpeed * (1 + mmLvl/10.0);
    }
    //Grid Speed (tiles/second) = Speed (100ths/min) / 6000 
    var gSpeed = 0;
    var estSec;
    if (Speed>0) {
      gSpeed = Speed/6000.0;//0.48333 mm=10, hs=9
      estSec = (parseFloat(dist)/gSpeed).toFixed(0);
    }
    ret.ETA = (parseInt((estSec+''))+30); 
    ret.etaStr = timestr (ret.ETA,1);
    //ret.etaStr = ret.ETA + ', ' + timestr (ret.ETA,1);
    //RS - Cities Relief Station Level
    //Friendly Speed = Speed * (1 + RS/2)
    if (t.ModelCity) {
      cityID = t.ModelCity.id;
      var building = getCityBuilding (cityID, 18);
      if (building) {
        fSpeed = Speed * (1 + parseInt(building.maxLevel)/2);
        gSpeed = fSpeed/6000;
        estSec = (dist/gSpeed).toFixed(0);
        ret.friendETA = parseInt((estSec+''))+30; 
        ret.friendEtaStr = timestr ((ret.friendETA+''),1);
      }
   }
    return ret;
  },
  
     JumpCity:function(city) {
      var t = Tabs.AllianceList;
      for (i=0;i<Seed.cities.length;i++) {
        if (Seed.cities[i][1]==city) var cityNum=i;
      }
      cityNum++;
      var obj = document.getElementById('citysel_'+cityNum);
      return t.ClickWin(window,obj,'click');
   },
   
   ClickWin:function(win,obj,evtName) {
    var evt = win.document.createEvent("MouseEvents");
    evt.initMouseEvent(evtName, true, true, win,
      0, 0, 0, 0, 0, false, false, false, false, 0, null);
    return !obj.dispatchEvent(evt);
   },
};


/*************************************** Train Tab ***********************************************/

Tabs.Train = {
  tabOrder : 3,
  type: 'Tools',
  tabLabel : unsafeWindow.g_js_strings.commonstr.train,
  cont : null,
  timer : null,
  stats : {},
  selectedCity : {},
  cityNum :0,
  trainTimer : null,
  running : false,
  gamble : {"1":{"min":"5","max":"15","cost":"2"},"2":{"min":"10","max":"25","cost":"4"}},
  nextAuto:       null,
  defenseOptions: "<option value='53'>Crossbow</option><option value='55'>Trebuchet</option><option value='60'>Trap</option><option value='61'>Caltrop</option><option value='62'>Spiked Barrier</option>",
  prevCityNo:     0,
  
  init : function (div){
    var t = Tabs.Train;
    t.cont = div;
    unsafeWindow.cancelTrain = t.butcancelTrain;
    unsafeWindow.cancelFort = t.butcancelFort;
   // <DIV style="max-height:1100px; height:1100px; overflow-y:auto">
    s = "<DIV style='max-height:870px; height:1100px; overflow-y:auto'><DIV id=trainTopSelect >\
      <DIV class=pbStat id=trainheader>"+unsafeWindow.g_js_strings.modal_openBarracks.trainttl+" & "+unsafeWindow.g_js_strings.modal_openWalls.builddefenses+"</div>\
      <DIV style='height:5px'></div><DIV>\
      <DIV style='text-align:center; margin-bottom:5px;'>"+unsafeWindow.g_js_strings.commonstr.city+": &nbsp; <span id=ptspeedcity></span></div>\
      <TABLE class=pbTab width=100%><TR valign=top><TD width=50%>\
      <TABLE align=center><TR><TD align=right>"+unsafeWindow.g_js_strings.modal_messages_viewdesertionreports.trooptypes+": </td><TD colspan=2>\
      <SELECT id=ptttType>";
     for (i=1;i<=16;i++) s+='<option value='+i+'>'+unsafeWindow.unitcost['unt'+i][0]+'</option>';
      s+="</select>  &nbsp; ("+unsafeWindow.g_js_strings.commonstr.max+" <span id=ptttSpMax></span>)</td></tr>\
        <TR><TD align=right>"+unsafeWindow.g_js_strings.modal_barracks_train.numtotrain+": </td><TD><INPUT id='ptttInpPS' size=5 type='text' value='0'\></td>\
        <TD><INPUT id='ptttButMaxPS' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.commonstr.max+"'\> &nbsp; (\
        "+unsafeWindow.g_js_strings.commonstr.max+" <span id=ptttSpMaxPS>0</span>)</td></tr>\
        <TR><TD align=right>"+unsafeWindow.buildingcost.bdg13[0]+": </td><TD><INPUT id='ptttInpSlots' size=2 type='text' value='1'\></td>\
        <TD width=75%><INPUT id='ptttButMaxSlots' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.commonstr.max+"'\> &nbsp;\
        ("+unsafeWindow.g_js_strings.commonstr.max+" <span id=ptttSpMaxSlots>1</span>)</td></tr>\
        <TR><TD align=right valign=top></td><TD colspan=2><INPUT type=CHECKBOX id=chkPop"+ (Options.maxIdlePop?' CHECKED ':'') +"> \
        <SPAN style='white-space:normal;'>"+unsafeWindow.g_js_strings.commonstr.use +" "+ unsafeWindow.g_js_strings.commonstr.workers+"</span>\
        <br><SELECT id=tutelage>\
        <option value='0'><CENTER>--- "+unsafeWindow.g_js_strings.commonstr.items+" "+unsafeWindow.g_js_strings.commonstr.speedup+" ---</center></option>\
        <option value='36'>"+ unsafeWindow.itemlist.i36.name+"</option>\
        <option value='37'>"+ unsafeWindow.itemlist.i37.name+"</option>\
        <option value='38'>"+ unsafeWindow.itemlist.i38.name+"</option>\
        </select>\
        <br><br><SELECT id=pttrgamble>\
        <option value='0'><CENTER>--- "+unsafeWindow.g_js_strings.commonstr.resources+" "+unsafeWindow.g_js_strings.commonstr.speedup+" ---</center></option>\
        <option value=1>Use "+ t.gamble[1].cost+"x resources ("+ t.gamble[1].min+" - "+t.gamble[1].max+"%)</option>\
        <option value=2>Use "+ t.gamble[2].cost+"x resources ("+ t.gamble[2].min+" - "+t.gamble[2].max+"%)</option>\
        </select>\
        </td></tr>\
        <TR><TD colspan=3 align=center><DIV id=pbTroopTimeEst></div></td></tr>\
        <TR><TD colspan=3 align=center><DIV style='height:10px'></div><INPUT id='ptttButDo' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.modal_openBarracks.trainttl+"'\
        ></td></tr>\
        </table></td><TD width=20></td><TD style='border-left:solid 2px;' width=50% align=center>\
        <TABLE align=center><TR><TD align=right>"+unsafeWindow.g_js_strings.modal_openWalls.builddefenses+": </td><TD colspan=2>\
        <SELECT id=pttdType>\
        <option value='53'>"+unsafeWindow.fortcost.frt53[0]+"</option>\
        <option value='55'>"+unsafeWindow.fortcost.frt55[0]+"</option>\
        <option value='60'>"+unsafeWindow.fortcost.frt60[0]+"</option>\
        <option value='61'>"+unsafeWindow.fortcost.frt61[0]+"</option>\
        <option value='62'>"+unsafeWindow.fortcost.frt62[0]+"</option>\
        </select> &nbsp; (<span id=pttdSpMax></span>)</td>\
        <TR><TD align=right>"+unsafeWindow.g_js_strings.modal_walls_train.numdefbuild+": </td><TD><INPUT id='pttdInpPS' size=5 type='text' value='0'\></td>\
        <TD><INPUT id='pttdButMaxPS' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.commonstr.max+"'\> &nbsp; ("+unsafeWindow.g_js_strings.commonstr.max+"\
         <span id=pttdSpMaxPS>0</span>)</td></tr>\
        <TR><TD align=right>"+unsafeWindow.g_js_strings.commonstr.space+"("+unsafeWindow.buildingcost.bdg19[0]+"): </td>\
        <TD><INPUT id='pttdInpSlots' size=2 type='text' value='1'\></td>\
        <TD width=75%><INPUT id='pttdButMaxSlots' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.commonstr.max+"'\>&nbsp; (\
        "+unsafeWindow.g_js_strings.commonstr.max+" <span id=pttdSpMaxSlots></span>)</td></tr>\
        <TR align=center><TD colspan=3><SPAN id=pttdSpace></span></td></tr>\
        <TR><TD colspan=3 align=center><DIV style='height:10px'>\
        <SELECT id=siege>\
        <option value='0'><CENTER>--- "+unsafeWindow.g_js_strings.commonstr.speedup+" ---</center></option>\
        <option value='26'>"+ unsafeWindow.itemlist.i26.name+"</option>\
        </select></div>\
        <BR><INPUT id='pttdButDo' type=submit class=pbButton value='"+unsafeWindow.g_js_strings.modal_openWalls.builddefenses+"'\></td></tr></table>\
        </td></tr></table></div></div>\
        <TABLE align=center width=425 class=pbTab><TR><TD><div id=ptTrainStatus style='overflow-y:auto; max-height:78px;'></div></td></tr></table>\
        <TABLE width=100%><TR><TD colspan=3><DIV id=divSTtop></div></td></tr>\
        <TR><TD width=50% style='padding-left:15px; padding-right:15px'><DIV style='text-align:center'>\
        <B>"+unsafeWindow.g_js_strings.commonstr.troops+" ("+unsafeWindow.g_js_strings.modal_openBarracks.trainingttl+")\
        &nbsp; (<SPAN id=statTTtot></span>)</b><BR><HR></div><DIV id=divSTleft style='overflow-y: auto; height:400px; max-height:700px'></div></td>\
         <TD width=50% style='padding-left:15px; padding-right:15px'><DIV style='text-align:center'><B>"+unsafeWindow.g_js_strings.modal_openWalls.defqueue+"&nbsp; (<SPAN\ id=statDTtot></span>)</b><BR><HR></div><DIV id=divSTright style='overflow-y: auto; height:210px; max-height:210px'></div></td></tr>\
         </div></div><BR>";
    t.cont.innerHTML = s;
    document.getElementById('ptttInpPS').addEventListener('keyup',function(){
        if (document.getElementById('ptttInpPS').value != "") t.dispTroopTrainTimes();
         else{
            document.getElementById('ptttInpPS').value = "0"
            t.dispTroopTrainTimes();
        }
    });
    document.getElementById('ptttType').addEventListener('change',function(){
        if (document.getElementById('ptttInpPS').value > 0) t.dispTroopTrainTimes(); 
    t.lastQueString = null;
    t.displayCityStats();
    });
    var dcp = new CdispCityPicker ('ptspeed', document.getElementById('ptspeedcity'), true, t.clickCitySelect, 0);
    t.TTspMax = document.getElementById ('ptttSpMax');
    t.TTspMaxPS = document.getElementById ('ptttSpMaxPS');
    t.TTspMaxSlots = document.getElementById ('ptttSpMaxSlots');
    t.TTbutMaxSlots = document.getElementById ('ptttButMaxSlots');
    t.TTbutMaxPerSlot = document.getElementById ('ptttButMaxPS');
    t.TTinpPerSlot = document.getElementById ('ptttInpPS');
    t.TTinpSlots = document.getElementById ('ptttInpSlots');
    t.TTselType = document.getElementById ('ptttType');
    t.TTbutDo = document.getElementById ('ptttButDo');
    t.TDspMax = document.getElementById ('pttdSpMax');
    t.TDspMaxPS = document.getElementById ('pttdSpMaxPS');
    t.TDspMaxSlots = document.getElementById ('pttdSpMaxSlots');
    t.TDbutMaxSlots = document.getElementById ('pttdButMaxSlots');
    t.TDbutMaxPerSlot = document.getElementById ('pttdButMaxPS');
    t.TDinpPerSlot = document.getElementById ('pttdInpPS');
    t.TDinpSlots = document.getElementById ('pttdInpSlots');
    t.TDselType = document.getElementById ('pttdType');
    t.TDbutDo = document.getElementById ('pttdButDo');
    t.TDspSpace = document.getElementById ('pttdSpace');
    t.divTrainStatus = document.getElementById ('ptTrainStatus');
          
    t.TTinpSlots.addEventListener ('change', t.updateTopTroops, false);
    t.TTbutMaxPerSlot.addEventListener ('click', t.clickTroopMaxPS, false);
    t.TTbutMaxSlots.addEventListener ('click', t.clickTroopMaxSlots, false);
    t.TTselType.addEventListener ('change', t.changeTroopSelect, false);
    t.TTbutDo.addEventListener ('click', t.clickTroopDo, false);
    t.TDinpSlots.addEventListener ('change', t.updateTopDef, false);
    t.TDselType.addEventListener ('change', t.changeDefSelect, false);
    t.TDbutMaxPerSlot.addEventListener ('click', t.clickDefMaxPS, false);
    t.TDbutMaxSlots.addEventListener ('click', t.clickDefMaxSlots, false);
    t.TDbutDo.addEventListener ('click', t.clickDefDo, false);
    document.getElementById ('chkPop').addEventListener ('change', t.clickCheckIdlePop, false);
    document.getElementById ('pttrgamble').addEventListener ('change', t.changeTroopSelect, false);
    
    document.getElementById ('chkPop').addEventListener ('change', t.clickCheckIdlePop, false);
    t.changeTroopSelect();
    t.changeDefSelect();
  },
  dispTroopTrainTimes:function(){
      var t = Tabs.Train;
      var TroopTypeID = parseInt(document.getElementById('ptttType').value);
      var NumOfTroops = parseInt(document.getElementById('ptttInpPS').value); 
      var TroopTime = unsafeWindow.modal_barracks_traintime(TroopTypeID,NumOfTroops);
      var TroopName = unsafeWindow.unitcost['unt'+ TroopTypeID][0];
      var TotalTime2x5 = TroopTime * 0.95;
      var TotalTime2x15 = TroopTime * 0.85;
      var TotalTime4x10 = TroopTime * 0.9;
      var TotalTime4x25 = TroopTime * 0.75;
      var TotalTimeLancelot = TroopTime * 0.7;
      var TotalTimeArthur = TroopTime * 0.5;
      var TotalTimeMerlin = TroopTime * 0.3;
      var TotalTTS = unsafeWindow.cm.ThroneController.effectBonus(77);
      var baseTime = t.calcBaseTrainTime(TroopTypeID,NumOfTroops);

      message =  '<TABLE align=center><TR>';
     // message += '<TR><TD><B>Base Time NO TR: '+ timestr(baseTime,true) +' </b></td></tr>';
      message += '<TR><TD>Time with ' + TotalTTS + '% Throne Boost : </td><TD>' + timestr(TroopTime,true) + '</td></tr>';
     // message += '<TR><TD>Time with Lacelot\'s : </td><TD>'+timestr(TotalTimeLancelot,true)+' </td></tr>';
     // message += '<TR><TD>Time with Arthur\'s : </td><TD>'+timestr(TotalTimeArthur,true)+' </td></tr>';
     // message += '<TR><TD>Time with Merlin\'s : </td><TD>'+timestr(TotalTimeMerlin,true)+'</td></tr>';
    //  message += '<TR><TD>Time with 2x Reso : </td><TD>'+ timestr(TotalTime2x15,true) + ' - ' + timestr(TotalTime2x5,true) + ' </td></tr>'; 
     // message += '<TR><TD>Time with 4x Reso : </td><TD>'+ timestr(TotalTime4x25,true) + ' - ' + timestr(TotalTime4x10,true) + ' </td></tr></table>';
      
      document.getElementById('pbTroopTimeEst').innerHTML = message;
  },
 calcBaseTrainTime:function(d, f) {
  var uw = unsafeWindow
    var c = +(uw.unitcost["unt" + d][7]) * f,
        e, k = {}, h = uw.seed.buildings["city" + uw.currentcityid],
        j = {}, l = uw.seed.knights["city" + uw.currentcityid],
        a, g = uw.seed.leaders["city" + uw.currentcityid];
    k.barracks = 0;
    k.workshop = 0;
    k.stable = 0;
    k.tech = 0;
    k.knight = 0;
    k.ultimate = 0;
    unsafeWindow.jQuery.each(h, function (n, m) {
        m.id = +(m[0]);
        m.level = +(m[1]);
        if (m.id === 13 && m.level > 0) k.barracks += (m.level + 9) 
        if (m.id === 16 && m.level > 0) if (+(d) >= 9) k.workshop = m.level
        if (m.id === 17 && m.level > k.stable) if (+(d) >= 7) k.stable = m.level
    });
    e = k.barracks / 10;
    c = Math.max(1, Math.ceil(c / e));
    e = 1;
    if (l) {
        a = l["knt" + g.combatKnightId];
        if (a) k.knight = (+(a.combatBoostExpireUnixtime) - uw.unixtime() > 0) ? (a.combat * 1.25) : a.combat
         else k.knight = 0  
    }
    if (uw.seed.tech) k.tech = uw.seed.tech.tch5 
    k.ultimate = k.workshop + k.stable + k.tech;
    e = e * (1 + (0.1 * k.ultimate) + (0.005 * k.knight));
    if (uw.cm.WorldSettings.isOn("GUARDIAN_MARCH_EFFECT")) {
        var b = uw.cm.guardianModalModel.getStoneTrainingSpeedBonus();
        e = e * (1 + b)
    }
    c = Math.max(1, Math.ceil(c / e));
    return c
},

  calcTRBoosts : function (StatID){
    var equipped = Seed.throne.slotEquip[1];
    var total = 0;
    for(var k = 0; k<equipped.length; k++){
      var item_id = equipped[k];
      var item = unsafeWindow.kocThroneItems[item_id];
      for(var i = 1; i<=item.quality; i++){
        var id = item['effects']['slot'+i]['id'];
        if(id == StatID){
          var tier = parseInt(item["effects"]["slot"+i]["tier"]);
          var level = item["level"];
          var p = unsafeWindow.cm.thronestats.tiers[id][tier];
          var Percent = p.base + ((level * level + level) * p.growth * 0.5);
          total += Percent;
        }
      }
    }
    return total;
  },
  hide : function (){
    var t = Tabs.Train;
    clearTimeout (t.timer);
  },
  
  show : function (){
    var t = Tabs.Train;
    clearTimeout (t.timer);
    t.displayCityStats();
    t.changeTroopSelect();
    t.changeDefSelect();
    t.timer = setTimeout (t.show, 2000);
  },

/*******  TROOPS  ******/  
  
  updateTopTroops : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TTinpSlots.value, 10);
    if (isNaN(slots) || slots<0)
      slots = 0;
    t.TTspMax.innerHTML = t.stats.MaxTrain;
    t.TTspMaxSlots.innerHTML = t.stats.barracks - t.stats.queued;
    if (slots<1 || (t.stats.barracks-t.stats.queued < 1))
      t.TTspMaxPS.innerHTML = 0;
    else
      t.TTspMaxPS.innerHTML = parseInt(t.stats.MaxTrain / slots);
  },
      
  
  clickTroopMaxPS : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TTinpSlots.value, 10);
    if (slots<1 || (t.stats.barracks-t.stats.queued < 1))
      t.TTinpPerSlot.value = 0;
    else
      t.TTinpPerSlot.value = parseInt(t.stats.MaxTrain / slots);
    t.dispTroopTrainTimes();
  },

  clickTroopMaxSlots : function (){
    var t = Tabs.Train;
    t.TTinpSlots.value = t.stats.barracks - t.stats.queued;
  },
  
  clickCitySelect : function (city){
    var t = Tabs.Train;
    t.selectedCity = city;
    t.lastQueString = null;   
    t.lastDQueString = null;   
    t.displayCityStats ();
    t.changeTroopSelect();
    t.changeDefSelect();
    t.JumpCity(city.name);
  },
  
  JumpCity:function(city) {
        var t = Tabs.AllianceList;
        for (i=0;i<Seed.cities.length;i++) {
          if (Seed.cities[i][1]==city) var cityNum=i;
        }
        cityNum++;
        var obj = document.getElementById('citysel_'+cityNum);
        return t.ClickWin(window,obj,'click');
     },
  
  ClickWin:function(win,obj,evtName) {
      var evt = win.document.createEvent("MouseEvents");
      evt.initMouseEvent(evtName, true, true, win,
        0, 0, 0, 0, 0, false, false, false, false, 0, null);
      return !obj.dispatchEvent(evt);
     },
  
  clickCheckIdlePop : function (){
    var t = Tabs.Train;
    if (document.getElementById ('chkPop').checked)
      Options.maxIdlePop = true;
    else
      Options.maxIdlePop = false;
    saveOptions ();
    t.displayCityStats ();
    t.changeTroopSelect ();
  },

  limitingFactor : null,
    
  changeTroopSelect : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    // unitcost: NAME, Food, Wood, Stone, Ore, Gold, Pop, ?
    var id = t.TTselType.value;
    t.lastTroopSelect = id;
    t.limitingFactor = null;
    var uc = unsafeWindow.unitcost['unt'+id];
  var actualuc = [];
  for(var r = 1; r<5; r++){
    if(document.getElementById('pttrgamble').value > 0)
      actualuc[r] = uc[r] * t.gamble[document.getElementById('pttrgamble').value].cost;
    else
      actualuc[r] = uc[r];
  }
    var max = 9999999999;
    if ( (t.stats.food / actualuc[1]) < max){
      max = t.stats.food / actualuc[1];
      t.limitingFactor = unsafeWindow.resourceinfo['rec1'];
    }
    if ( (t.stats.wood / actualuc[2]) < max){
      max = t.stats.wood / actualuc[2];
      t.limitingFactor = unsafeWindow.resourceinfo['rec2'];
    }
    if ( (t.stats.stone / actualuc[3]) < max){
      max = t.stats.stone / actualuc[3];
      t.limitingFactor = unsafeWindow.resourceinfo['rec3'];
    }
    if ( (t.stats.ore / actualuc[4]) < max){
      max = t.stats.ore / actualuc[4];
      t.limitingFactor = unsafeWindow.resourceinfo['rec4'];
    }
    if ( (t.stats.idlePop / uc[6]) < max){
      max = t.stats.idlePop / uc[6];
      t.limitingFactor = 'pop';
    }
    t.stats.MaxTrain = parseInt (max);
    if (t.stats.MaxTrain < 0)
      t.stats.MaxTrain = 0;
    if (matTypeof(uc[8]) == 'object'){
      for (k in uc[8]){  // check building requirement
    var isPrestige = getCityPrestige(cityId);
        var b = getCityBuilding (cityId, k.substr(1));
    if(isPrestige){
      var bid = parseInt(k.substr(1));
      switch(bid){
        case 17: //Stable
          b.maxLevel = 12;
        case 16: //Workshop
          b.maxLevel = 12;
        case 15: //Blacksmith
          b.maxLevel = 12;
      }
    }
        if (b.maxLevel < uc[8][k][1]){
          t.stats.MaxTrain = 0;
          t.limitingFactor = null;
          break;
        }
      }
    }
    if (matTypeof(uc[9]) == 'object'){
      for (k in uc[9]){    // check tech requirement
        if (parseInt(Seed.tech['tch'+k.substr(1)]) < uc[9][k][1]){
          t.stats.MaxTrain = 0;
          t.limitingFactor = null;
          break;
        }
      }
    }
  if (t.limitingFactor){
    document.getElementById('ptttr_'+ t.limitingFactor).className = 'boldRed';
    document.getElementById('ptttr2_'+ t.limitingFactor).className = 'boldRed';
  }    
    t.updateTopTroops();
  },

  clickTroopDo : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    var unitId = t.TTselType.value;
    var perSlot = parseInt(t.TTinpPerSlot.value, 10);
    var numSlots = parseInt(t.TTinpSlots.value, 10);
    
    t.displayCityStats ();
    if (t.running){
      t.stopTraining('<SPAN class=boldRed>Training cancelled by user</span>');
      return; 
    }    
    if (perSlot<1){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>'+unsafeWindow.g_js_strings.commonstr.invalid +' ('+unsafeWindow.g_js_strings.modal_barracks_train.numtotrain+')</font>';
      return;
    }
    if (perSlot*numSlots > t.stats.MaxTrain){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Can\'t train that many troops (max is '+ t.stats.MaxTrain +' total)</font>';
      return;
    }
    if (numSlots<1 || numSlots>t.stats.barracks - t.stats.queued){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>'+unsafeWindow.g_js_strings.commonstr.invalid +' ('+unsafeWindow.buildingcost.bdg13[0]+')</font>';
      return;
    }

  var tut = document.getElementById ('tutelage').value;
  var gamble = document.getElementById ('pttrgamble').value;
    
    t.TDbutDo.disabled = true;
    t.TTbutDo.className = 'ptButCancel';
    t.TTbutDo.value = 'CANCEL';
    var que = [];
    for (var i=0; i<numSlots; i++)
      que.push (['T', unitId, parseInt (perSlot)]);
    t.divTrainStatus.innerHTML = '';
    t.running = true;
    t.doQueue (cityId, tut, gamble, que);
  },

  
/*******  DEF  ******/  
  
  updateTopDef : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TDinpSlots.value, 10);
    if (isNaN(slots) || slots<0)
      slots = 0;
    t.TDspMax.innerHTML = unsafeWindow.g_js_strings.commonstr.max+':'+ t.stats.MaxDefTrain +'&nbsp; '+unsafeWindow.g_js_strings.commonstr.owned+':'+ t.stats.defOwned;   
    t.TDspMaxSlots.innerHTML = t.stats.wallLevel-t.stats.Dqueued;
    if (slots<1)
      t.TDspMaxPS.innerHTML = 0;
    else
      t.TDspMaxPS.innerHTML = parseInt(t.stats.MaxDefTrain / slots);

    t.TDspSpace.innerHTML = unsafeWindow.buildingcost.bdg19[0]+' ('+unsafeWindow.g_js_strings.guardian.cl1+'): <B>'+ t.stats.wallLevel +'\
    </b><BR>'+unsafeWindow.g_js_strings.modal_openWalls.walldef+': \
    '+ (t.stats.wallSpaceUsed+t.stats.wallSpaceQueued)  +'/<B>'+ t.stats.wallSpace +'</b><BR>\
        '+unsafeWindow.g_js_strings.modal_openWalls.fielddef+': '+ (t.stats.fieldSpaceUsed+t.stats.fieldSpaceQueued) +'/<B>'+ t.stats.fieldSpace +'</b>';
  },


  changeDefSelect : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    // unitcost: NAME, Food, Wood, Stone, Ore, Gold, Pop, ?
    var id = t.TDselType.value;
    t.lastDefSelect = id;
    t.stats.defOwned = parseInt(Seed.fortifications['city' + cityId]['fort'+id]);    
    var uc = unsafeWindow.fortcost['frt'+id];
    var max = 9999999999;
    if ( (t.stats.food / uc[1]) < max)
      max = t.stats.food / uc[1];
    if ( (t.stats.wood / uc[2]) < max)
      max = t.stats.wood / uc[2];
    if ( (t.stats.stone / uc[3]) < max)
      max = t.stats.stone / uc[3];
    if ( (t.stats.ore / uc[4]) < max)
      max = t.stats.ore / uc[4];
    if ( (t.stats.idlePop / uc[6]) < max)
      max = t.stats.idlePop / uc[6];
    t.stats.MaxDefTrain = parseIntNan (max);
    if (t.stats.MaxDefTrain < 0)
      t.stats.MaxDefTrain = 0;
    if (matTypeof(uc[8]) == 'object'){
      for (k in uc[8]){  // check building requirement
        var b = getCityBuilding (cityId, k.substr(1));
        if (k.substr(1)==15 && Seed.cityData.city[cityId].isPrestigeCity) b.maxLevel=12;
        if (k.substr(1)==16 && Seed.cityData.city[cityId].isPrestigeCity) b.maxLevel=12;
        if (b.maxLevel < uc[8][k][1]){
          t.stats.MaxDefTrain = 0;
          break;
        }
      }
    }
    if (matTypeof(uc[9]) == 'object'){
      for (k in uc[9]){    // check tech requirement
        if (parseInt(Seed.tech['tch'+k.substr(1)]) < uc[9][k][1]){
          t.stats.MaxDefTrain = 0;
          break;
        }
      }
    }
    var spaceEach = parseInt(unsafeWindow.fortstats["unt"+ id][5]);
    if (id<60) var spaceAvail = t.stats.wallSpace - t.stats.wallSpaceUsed - t.stats.wallSpaceQueued;
    else var spaceAvail = t.stats.fieldSpace - t.stats.fieldSpaceUsed - t.stats.fieldSpaceQueued;
    if ( t.stats.MaxDefTrain * spaceEach > spaceAvail) t.stats.MaxDefTrain = parseInt(spaceAvail / spaceEach); 
    t.updateTopDef();
  },
  
  clickDefMaxPS : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TDinpSlots.value, 10);
    if (slots<1)
      t.TDinpPerSlot.value = 0;
    else
      t.TDinpPerSlot.value = parseInt(t.stats.MaxDefTrain / slots);
  },

  clickDefMaxSlots : function (){
    var t = Tabs.Train;
    t.TDinpSlots.value = t.stats.wallLevel-t.stats.Dqueued;
  },
    
  clickDefDo : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    var unitId = t.TDselType.value;
    var perSlot = parseInt(t.TDinpPerSlot.value, 10);
    var numSlots = parseInt(t.TDinpSlots.value, 10);
    
    t.displayCityStats ();
    if (t.running){
      t.stopTraining('<SPAN class=boldRed>'+unsafeWindow.g_js_strings.commonstr.cancelled+'</span>');
      return; 
    }    
    if (perSlot<1)return;
    if (perSlot*numSlots > t.stats.MaxDefTrain){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>'+ unsafeWindow.g_js_strings.modal_attack.maxtroops +': '+ t.stats.MaxDefTrain +'</font>';
      return;
    }
    if (numSlots<1 || numSlots > t.stats.wallLevel-t.stats.Dqueued){
        t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>'+unsafeWindow.g_js_strings.commonstr.invalid+' ()</font>';
      return;
    }
    var siege = document.getElementById ('siege').value;
    t.TTbutDo.disabled = true;
    t.TDbutDo.className = 'ptButCancel';
    t.TDbutDo.value = 'CANCEL';
    var que = [];
    for (var i=0; i<numSlots; i++)
      que.push (['T', unitId, parseInt (perSlot)]);
    t.divTrainStatus.innerHTML = '';
    t.running = true;
    t.doDefQueue (cityId, siege, que);
  },

  doDefQueue : function (cityId, siege, que, errMsg){
    var t = Tabs.Train;
    clearTimeout (t.trainTimer);
    try {
      t.displayCityStats();
      if (errMsg){
        t.stopTraining ('<SPAN class=boldRed>ERROR: '+ errMsg +'</span>');
        return;
      }
      var cmd = que.shift();
      if (!cmd){
        t.stopTraining ('<B>Done queueing defenses.</b>');
        return;
      }
      if (cmd[0] == 'T'){
        t.dispTrainStatus ('Training '+ cmd[2] +' '+  fortNamesShort[cmd[1]] +' at '+ Cities.byID[cityId].name +' ('+ que.length +' slots remaining)<BR>');
        doDefTrain ( cityId, siege, cmd[1], cmd[2], 
          function(errMsg){
            t.trainTimer = setTimeout(function (){Tabs.Train.doDefQueue(cityId, siege, que, errMsg);}, (Math.random()*3500)+1500);
          } );
      }
    } catch (err) {
      logit (inspect (err, 8, 1));
      t.stopTraining ('<SPAN class=boldRed>PROGRAM ERROR: '+ err.message +'</span>');
    }
  },
  

  // fix KofC bugs ....
  // if first start time > now, make it now
  // if any end time != next start time, fix it
  fixQueTimes : function (q){
    var now = unixTime();
    if (q[0][2] > now)
      q[0][2] = now;
    for (var i=0; i<q.length; i++){
      if (q[i+1]!=null && q[i+1][2]!=q[i][3])
        q[i][3] = q[i+1][2];
    }        
  },

  expireTheQueue : function (q){
    if (q==null)
      return;
    var now = unixTime();
    while (q.length>0 && (q[0][3] - now) < 1)
      q.shift();
  },
    
  displayCityStats : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
  var isSpecial = false;
  if(t.TTselType.value > 12){
    isSpecial = true;
  }
    t.stats.food = parseInt (Seed.resources['city'+cityId].rec1[0]/3600);
    t.stats.wood = parseInt (Seed.resources['city'+cityId].rec2[0]/3600);
    t.stats.stone = parseInt (Seed.resources['city'+cityId].rec3[0]/3600);
    t.stats.ore = parseInt (Seed.resources['city'+cityId].rec4[0]/3600);
    t.stats.gold = Seed.citystats['city'+cityId].gold[0];
    if (Options.maxIdlePop) t.stats.idlePop = parseInt(Seed.citystats['city'+cityId].pop[0]);
    else t.stats.idlePop = parseInt(Seed.citystats['city'+cityId].pop[0]) - parseInt(Seed.citystats['city'+cityId].pop[3]);
      t.stats.barracks = getCityBuilding (cityId,13).count;     
      t.stats.barracks += getCityBuilding (cityId,22).count;
      t.stats.barracks += getCityBuilding (cityId,24).count;
    var m = '<CENTER><B>'+ Cities.byID[cityId].name +' &nbsp; ('+ Cities.byID[cityId].x +','+ Cities.byID[cityId].y +')</b></center><HR>';

    m += '<TABLE class=pbTab width=100%><TR align=center>';
    for(i=1;i<=6;i++){
      m += '<TR><TD width=75px>'+unsafeWindow.unitcost['unt'+i][0]+'</td><TD width=60px>'+addCommas(parseInt(Seed.units['city'+cityId]['unt'+i]))+'</td>';
      m += '<TD width=75px>'+unsafeWindow.unitcost['unt'+(i+6)][0]+'</td><TD width=60px>'+addCommas(parseInt(Seed.units['city'+cityId]['unt'+(i+6)]))+'</td>';
      if (i<=4) m += '<TD width=75px><SPAN id=ptttr_'+unsafeWindow.resourceinfo['rec'+i]+'>'+unsafeWindow.resourceinfo['rec'+i]+'</span></td><TD width=60px><SPAN id=ptttr2_'+unsafeWindow.resourceinfo['rec'+i]+'>'+addCommas(parseInt(Seed.resources['city'+cityId]['rec'+i][0]/3600))+'</span></td>';
      //if (i==5) m += '<TD width=75px><SPAN id=ptttr_gold>'+unsafeWindow.resourceinfo['rec0']+'</span></td><TD width=60px><SPAN id=ptttr2_gold>'+addCommas(Seed.citystats['city'+cityId].gold[0])+'</span></td>';
      if (i==6) m += '<TD width=75px><SPAN id=ptttr_pop>'+unsafeWindow.g_js_strings.showPopTooltip.idlepop+'</td><TD width=60px><SPAN id=ptttr2_pop>'+addCommas(t.stats.idlePop)+'</td>';
      m+='</tr>';
    }
    m+='</table>';
    document.getElementById ('divSTtop').innerHTML =m;
    
// troop queue .... 
    var totTime = 0;
    var q = Seed.queue_unt['city'+cityId];
    t.expireTheQueue(q);
    var qs = q.toString();
    var now = unixTime();
    // if (q!=null && q.length>0)
      // totTime = q[q.length-1][3] - now;
    if ( qs == t.lastQueString){
      if (q!=null && q.length>0){
    var cur = 0;
    for(var i = 0; i<q.length; i++){
      if(q[i][7] && isSpecial){
        cur = q[i][3] - now;
        break;
      }
      if(!q[i][7] && !isSpecial){
        cur = q[i][3] - now;
        break;
      }
    }
    if(document.getElementById ('ptttfq'))
      document.getElementById ('ptttfq').innerHTML = timestr(cur, true);
      }
    } else {
      t.lastQueString = qs;
      t.stats.queued = 0;
      m = '<TABLE align=center class=pbTab>';
      if (q!=null && q.length>0 ){
    if(!getCityPrestige(cityId))
      t.fixQueTimes (q);
        // t.stats.queued = q.length;
        first = true;
        for (var i=0; i<q.length; i++){
      if(isSpecial && q[i][0] < 13){
      continue;
      }
      if(!isSpecial && q[i][0] >= 13){
      continue;
      }
      
          start = q[i][2];
          end = q[i][3];
      if(end > totTime)
      totTime = end;
          if (first)
            actual = end - now;
          else
            actual = end - lastEnd;
          if (actual < 0)
            actual = 0;
          q[i][6] = cityId;
      //q[i][7] If true means special troop training
          // if(q[i][7] && isSpecial)
          m += '<TR align=right><TD width="5px"><A><DIV onclick="cancelTrain('+ q[i][0]+','+q[i][1]+','+q[i][2]+','+q[i][3]+','+q[i][5]+','+q[i][6]+','+i +')">X</div></a></td>';
          m += '<TD>'+ q[i][1] +' </td><TD align=left> '+ unsafeWindow.unitcost['unt'+q[i][0]][0];
          if (first)
            m += '</td><TD> &nbsp; '+  timestr(end-start, true) +'</td><TD> (<SPAN id=ptttfq>'+ timestr(actual, true) +'</span>)';
          else
            m += '</td><TD> &nbsp; '+  timestr(actual, true) +'</td></tr>'; 
          lastEnd = end;
          first = false;
      t.stats.queued++;
        }
      }
      m += '</table>';
      // '<DIV style="max-height:1100px; height:1100px; overflow-y:auto">,;
      document.getElementById ('divSTleft').innerHTML = m;
    t.totTime = totTime;
    
    }
    m = t.stats.queued +' ' + unsafeWindow.g_js_strings.commonstr.oftx +' ';
    if (t.stats.queued >= 0)
    m += t.stats.barracks;
  
    if ((t.totTime-now) > 0)
      m += ' - '+ unsafeWindow.g_js_strings.commonstr.time + ': '+ unsafeWindow.timestr(t.totTime-now);
    document.getElementById ('statTTtot').innerHTML = m;
    /// 
    
    ///
     // m += '<TABLE align=center class=pbTab>test</table>'
// defense queue ....
    getWallInfo (cityId, t.stats);    
    var totTime = 0;
    var q = Seed.queue_fort['city'+cityId];
    t.expireTheQueue(q);
    var qs = q.toString();
    if (q!=null && q.length>0)
      totTime = q[q.length-1][3] - now;
    if ( qs == t.lastDQueString){
      if (q!=null && q.length>0){
        var cur = q[0][3] - now;
        document.getElementById ('pttdfq').innerHTML = timestr(cur, true);
      }
    } else {
      t.lastDQueString = qs;
      t.stats.Dqueued = 0;
      t.stats.wallSpaceQueued = 0;
      t.stats.fieldSpaceQueued = 0;
      m = '<TABLE align=center class=pbTab>';
      if (q!=null && q.length > 0 ){
        t.fixQueTimes (q);
        t.stats.Dqueued = q.length;
        first = true;
        for (i=0; i<q.length; i++){
          if (q[i][0] < 60)          
            t.stats.wallSpaceQueued += parseInt(unsafeWindow.fortstats["unt"+ q[i][0]][5]) * parseInt(q[i][1]);
          else          
            t.stats.fieldSpaceQueued += parseInt(unsafeWindow.fortstats["unt"+ q[i][0]][5]) * parseInt(q[i][1]);
          start = q[i][2];
          end = q[i][3];
          if (first)
            actual = end - now;
          else
            actual = end - lastEnd;
          if (actual < 0)
            actual = 0;
      q[i][7]=cityId;
          m += '<TR align=right><TD width="5px"><A><DIV onclick="cancelFort('+ q[i][0]+','+q[i][1]+','+q[i][2]+','+q[i][3]+','+q[i][5]+','+q[i][6]+','+q[i][7] +','+ i +')">X</div></a></td>'
          m += '<TD>'+ q[i][1] +' </td><TD align=left> '+ fortNamesShort[q[i][0]];
          if (first)
            m += '</td><TD> &nbsp; '+  timestr(end-start, true) +'</td><TD> (<SPAN id=pttdfq>'+ timestr(actual, true) +'</span>)';
          else
            m += '</td><TD> &nbsp; '+  timestr(actual, true) +'</td></tr>'; 
          lastEnd = end;
          first = false;
        }
      }
      m += '</table>';
      document.getElementById ('divSTright').innerHTML = m;
    }
    m = t.stats.Dqueued +' slots';
    if (totTime > 0)
      m += ', '+ unsafeWindow.timestr(totTime);
    document.getElementById ('statDTtot').innerHTML = m;
  },
  
  
  dispTrainStatus : function (msg){
    var t = Tabs.Train;
    t.divTrainStatus.innerHTML = msg + t.divTrainStatus.innerHTML;
  },

  butcancelTrain : function (typetrn, numtrptrn, trnTmp, trnETA, trnNeeded, cityId, trainingId){
    var t = Tabs.Train;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pf =0;
    params.requestType = "CANCEL_TRAINING";
    params.cityId = cityId;
    params.typetrn = typetrn;
    params.numtrptrn =  numtrptrn;
    params.trnETA = trnETA;
    params.trnTmp = trnTmp;
    params.trnNeeded = trnNeeded;
    
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelTraining.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (message) {
        var rslt=eval("("+message.responseText+")");
        if (rslt.ok) {
          var k=0;
          for(var j=0;j<Seed.queue_unt["city"+cityId].length;j++){
            if(j>trainingId){
              Seed.queue_unt["city"+cityId][j][2]=parseInt(rslt.dateTraining[k]["start"]);
              Seed.queue_unt["city"+cityId][j][3]=parseInt(rslt.dateTraining[k]["end"]);
              k++;
            }
          }
      
      Seed.queue_unt["city"+cityId].splice(trainingId,1);
      for(var i=1;i<5;i++){
        var totalReturn=parseInt(unsafeWindow.unitcost["unt"+typetrn][i])*parseInt(numtrptrn)*3600/2;
        Seed.resources["city"+cityId]["rec"+i][0]=parseInt(Seed.resources["city"+cityId]["rec"+i][0])+totalReturn;
      }
        } 
        },
        onFailure: function () {
        },
    });
  },
  
 butcancelFort : function (typefrt, numtrpfrt, frtTmp, frtETA, frtNeeded, frtid, cityId, queueId){
   var t = Tabs.Train;
   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
   
   params.pf =0;
   params.requestType = "CANCEL_FORTIFICATIONS";
   params.cityId = cityId;
   params.typefrt = typefrt;
   params.numtrpfrt =  numtrpfrt;
   params.frtETA = frtETA;
   params.frtTmp = frtTmp;
   params.frtNeeded = frtNeeded;
   params.frtid = frtid;
   
   new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelFortifications.php" + unsafeWindow.g_ajaxsuffix, {
       method: "post",
       parameters: params,
       onSuccess: function (message) {
       var rslt=eval("("+message.responseText+")");
       if (rslt.ok) {
      var k=0;
      for(var j=0;j<Seed.queue_fort["city"+cityId].length;j++){
        if(j>queueId){
          Seed.queue_fort["city"+cityId][j][2]=parseInt(rslt.dateFortifications[k]["start"]);
          Seed.queue_fort["city"+cityId][j][3]=parseInt(rslt.dateFortifications[k]["end"]);
          k++;
        }
      }
      unsafeWindow.update_seed(rslt.updateSeed);
      Seed.queue_fort["city"+cityId].splice(queueId,1);
      for(var i=1;i<5;i++){
        Seed.resources["city"+cityId]["rec"+i][0]=parseInt(Seed.resources["city"+cityId]["rec"+i][0])+totalReturn;
      }
    }
       },
       onFailure: function () {
       },
   });
 },
 
  
  stopTraining : function (msg){
    var t = Tabs.Train;
    clearTimeout (t.trainTimer);
    t.trainTimer = null;
    t.dispTrainStatus (msg +'<BR>');
    t.TDbutDo.disabled = false;
    t.TTbutDo.disabled = false;
    t.TTbutDo.value = unsafeWindow.g_js_strings.modal_openBarracks.trainttl;
    t.TDbutDo.value = unsafeWindow.g_js_strings.modal_openWalls.builddefenses;
    t.TTbutDo.className = '';
    t.TDbutDo.className = '';
    t.running = false;
  },
  
  
  doQueue : function (cityId, tut, gamble, que, errMsg){
    var t = Tabs.Train;
    clearTimeout (t.trainTimer);
    try {
      t.displayCityStats();
      if (errMsg){
        t.stopTraining ('<SPAN class=boldRed>'+ errMsg +'</span>');
        return;
      }
      var cmd = que.shift();
      if (!cmd){ 	
        t.stopTraining ('<B>'+unsafeWindow.g_js_strings.update_queue.troopqueue+'</b>');
        return;
      }
      if (cmd[0] == 'T'){
        t.dispTrainStatus (unsafeWindow.g_js_strings.modal_barracks_train.starttraining+': '+ cmd[2] +' '+  unsafeWindow.unitcost['unt'+cmd[1]][0] +' at '+ Cities.byID[cityId].name +' ('+ que.length +' slots remaining)<BR>');
        doTrain (cityId, tut, gamble, cmd[1], cmd[2], 
          function(errMsg){
            if (t.running)
              t.trainTimer = setTimeout(function (){Tabs.Train.doQueue(cityId, tut, gamble, que, errMsg);}, (Math.random()*2500)+1000 );
          }
        );
      }
    } catch (err) {
      t.stopTraining  ('<SPAN class=boldRed>'+unsafeWindow.g_js_strings.barbarian.erroroccured +' '+ err.message +'</span>');
    }
  },

}

/*********************************** Map tab ***********************************/
Tabs.Map = {
	tabOrder : 8,
	tabLabel : document.getElementById('mod_views_map').innerHTML,
	type: 'Tools',
	myDiv : null,

  	init : function (div){
	    var t = Tabs.Map;
	    t.myDiv = div;
	    fortmight = {
	      u53: "4",
	      u55: "7",
	      u60: "1",
	      u61: "2",
	      u62: "3",
	    };
	    var t = Tabs.Map;
	    var m = '<DIV style="max-height:1100px; height:1100px; overflow-y:auto"><DIV class=pbStat>PROVINCE MAP</div><BR><DIV id=ptProvMap style="height:'+ provMapCoords.imgHeight +'px; width:'+ provMapCoords.imgWidth +'px; background-repeat:no-repeat; background-image:url(\''+ URL_PROVINCE_MAP +'\')"></div>';
	    m+= '<BR><DIV class=pbStat>DISTANCE CALCULATOR</div><DIV class=ptentry><TABLE align=center cellpadding=1 cellspacing=0>\
	      <TR><TD class=xtab align=left><INPUT id=plot type=checkbox>Plot coords on map.</td></tr>\
	      <TR><TD class=xtab align=left><B>First Location: </b></td><TD  class=xtab> X: <INPUT id=calcX type=text\> Y: <INPUT id=calcY type=text\> Or, choose city: <SPAN id=ptloc1></span></td></tr>\
	      <TR><TD class=xtab align=left><B>Second Location: </b></td><TD class=xtab> X: <INPUT id=calcX2 type=text\> Y: <INPUT id=calcY2 type=text\> Or, choose city: <SPAN id=ptloc2></span></td></tr></table>\
	      <CENTER><DIV style="width:60%; font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptdistout></div></div>\
	      <BR></center></div>';
	    t.myDiv.innerHTML = m +'</div>';
	    
	    for (var c=0; c<Cities.numCities; c++) t.makeCityImg (c, document.getElementById('ptProvMap'));
		new CdispCityPicker ('ptloc1', document.getElementById('ptloc1'), true, t.eventLocChanged, 0).bindToXYboxes(document.getElementById('calcX'), document.getElementById('calcY'));
	    new CdispCityPicker ('ptloc2', document.getElementById('ptloc2'), true, t.eventLocChanged, 0).bindToXYboxes(document.getElementById('calcX2'), document.getElementById('calcY2'));
	    t.eventLocChanged(Cities.cities[0], Cities.cities[0].x, Cities.cities[0].y);
	    document.getElementById('plot').addEventListener('change', function(){
	       	t.plotCityImg(0, document.getElementById('ptProvMap'), document.getElementById('calcX').value, document.getElementById('calcY').value);
		    t.plotCityImg(1, document.getElementById('ptProvMap'), document.getElementById('calcX2').value, document.getElementById('calcY2').value);
	    }, false);
  	},
	hide : function (){},
  	show : function (){},

  	makeCityImg : function (cityNum, eMap){
	    var t = Tabs.Map;
	    var city = Cities.cities[cityNum];
	    var x = parseInt((provMapCoords.mapWidth * city.x) / 750);
	    var y = parseInt((provMapCoords.mapHeight * city.y) / 750);
	    var ce = document.createElement ('div');
	    ce.style.background = 'black';
	    ce.style.opacity = '1.0';
	    ce.style.position='relative';
	    ce.style.display='block';
	    ce.style.width='14px';
	    ce.style.height='16px';
	    ce.style.border='1px solid #fff';
	    ce.style.color = 'white';
	    ce.style.textAlign = 'center';
	    ce.style.top = (y+provMapCoords.topMargin-(cityNum*16)-8) +'px';      
	    ce.style.left = (x+provMapCoords.leftMargin-7) +'px';
	    eMap.appendChild(ce);
	    ce.innerHTML = (cityNum+1) +'';
  	},
  
  	plotCityImg : function (cityNum, eMap, x, y){
	    var t = Tabs.Map;
	    var xplot = parseInt((provMapCoords.mapWidth * x) / 750);
	    var yplot = parseInt((provMapCoords.mapHeight * y) / 750);
		if(document.getElementById('plotmap_'+cityNum) == null){
			var ce = document.createElement ('div');
			ce.style.background = 'white';
			ce.id = 'plotmap_'+cityNum;
			ce.style.opacity = '1.0';
			ce.style.position='relative';
			ce.style.display='block';
			ce.style.width='14px';
			ce.style.height='16px';
			ce.style.border='1px solid #fff';
			ce.style.color = 'black';
			ce.style.textAlign = 'center';
		} else ce = document.getElementById('plotmap_'+cityNum);
	    ce.style.top = (yplot+provMapCoords.topMargin-((Cities.numCities+cityNum)*16)-8) +'px';      
	    ce.style.left = (xplot+provMapCoords.leftMargin-7) +'px';
	    eMap.appendChild(ce);
	    ce.innerHTML = (cityNum+1) +'';
	},
  
	eventLocChanged : function (city, x, y){
		var t = Tabs.Map;
		var x1 = parseInt(document.getElementById('calcX').value);
		var x2 = parseInt(document.getElementById('calcX2').value);
		if (isNaN(x2)) return;
		var y1 = parseInt(document.getElementById('calcY').value);
		var y2 = parseInt(document.getElementById('calcY2').value);
		var m = 'The distance from '+ x1 +','+ y1 +' to '+ x2 +','+ y2 +' is: &nbsp;<B>'+ distance (x1, y1, x2, y2).toFixed(2) +'</b>';
		document.getElementById('ptdistout').innerHTML = m;
		if (document.getElementById('plot').checked){
		    t.plotCityImg(0, document.getElementById('ptProvMap'), x1, y1);
		    t.plotCityImg(1, document.getElementById('ptProvMap'), x2, y2);
		}
	},
}


/*************** KNIGHTS TAB *********************/
Tabs.Knights = {
	tabOrder : 4,
	tabLabel : unsafeWindow.g_js_strings.commonstr.knight,
	type : 'Tools',
	myDiv : null,
	displayTimer : null,
	action : 0,

	init : function (div){
		var t = Tabs.Knights;
		t.myDiv = div;
		unsafeWindow.ptAssignSkill = t.clickedAssignPoints;
		unsafeWindow.ptAssignTunes = t.clickedAssignTune; 
		unsafeWindow.ptButDismiss = t.postDismissKnight; 
		t.myDiv.innerHTML = '<DIV id=ptknightdiv style="max-height:600px; height:600px; max-width:900px; width:900px; overflow-y:auto">';
	},

	hide : function (){
		var t = Tabs.Knights;
		clearTimeout (t.displayTimer);
	},

  show : function (){
    var t = Tabs.Knights;
	clearTimeout (t.displayTimer);
    
    function _dispKnight (roleId, knight, numcid){
      var rid = roleId;
      if (roleId==null) rid = 1;
      var sty='';  
      if (row++ % 2) sty = 'class=ptOddrow ';        
      m = '<TR '+ sty +'valign=top align=right><TD><B>'+ (roleId==null ? '':KnightRoles[rid][0]) +'</b></td><TD align=left>';
      if (knight == null) {
        m += '--------</td><TD colspan=4></td><TD class=ptentry colspan=5></td><TD colspan=2></td></tr>';
      } else {
        var level = parseInt(Math.sqrt(parseInt(knight.experience) / 75)) + 1;
        var unpoints = level - parseInt(knight.skillPointsApplied);
        var salary = (parseInt(knight.skillPointsApplied) + 1) * 20;
        totSalary += salary;
        var ass = '';
        if (knight.knightStatus == 10){
          ass = '<TD class=ptentry align=left colspan=4>Marching</td>';
        } else {  
          if (unpoints > 0){
            unpoints = '<SPAN class="boldRed">'+ unpoints +'</span>';
          	for (var i=0; i<4; i++){
	            var sty = 'padding-left:1px;';
	            if (i == rid) sty += 'font-weight:bold;color:#116654';
	            if (t.action==2) t.clickedAssignPoints(null,cid,knight.knightId,i);  
	            if (t.action==1) t.clickedAssignPoints(null,cid,knight.knightId,1);     
	            ass += '<TD class=ptentry align=left style="'+ sty +'"><A style="'+ sty +'" onclick="ptAssignSkill(this,' + cid +','+ knight.knightId +','+ i +')">['+ KnightRoles[i][2] +'] &nbsp;</a></td>'; 
         	}
          } 
          else
            ass = '<TD class=ptentry colspan=4></td>';
        }  
        var skills = [];
        for (var i=0; i<4; i++){
          if (i == rid) skills[i] = '<B>'+ knight[KnightRoles[i][1]] +'</b>'; 
          else skills[i] = knight[KnightRoles[i][1]]; 
        }
		var item211="0";
        var item221="0";
        var item231="0";
        var item241="0";
        if (Seed.items.i211) item211='<a onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ boost_modal(1,'+ knight.knightId +');return false;}, 500);">'+Seed.items.i211+'</a>';
        if (Seed.items.i221) item221='<a onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ boost_modal(2,'+ knight.knightId +');return false;}, 500);">'+Seed.items.i221+'</a>';
        if (Seed.items.i231) item231='<a onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ boost_modal(3,'+ knight.knightId +');return false;}, 500);">'+Seed.items.i231+'</a>';
        if (Seed.items.i241) item241='<a onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ boost_modal(4,'+ knight.knightId +');return false;}, 500);">'+Seed.items.i241+'</a>';
        m += '<a title="Assign role" onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ assign_role_modal('+ knight.knightId +');return false;}, 500);">'+knight.knightName + '</td><TD>'+strButton14('Dismiss', 'onclick="ptButDismiss('+knight.knightId + ','+cid+')" id=tileId_') +'</td><TD>'+ skills[0] +' ('+item211+')</td><TD>'+ skills[1] +' ('+item221+')</td><TD>'+ skills[2] +' ('+item231+')</td><TD>' + skills[3] +' ('+item241+')</td><TD class=ptentry>'+ unpoints +'</td>'+ ass +'<TD><a title="EXP Boost" onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){  xpBoost_modal('+ knight.knightId +');return false; }, 500);">'+ level +'</a></td><td><a onclick="citysel_click(document.getElementById(\'citysel_'+ (numcid+1)+'\'));setTimeout (function (){ loyalBoost_modal('+ knight.knightId +');return false;}, 500);">'+knight.loyalty+'</a></td><TD>'+ addCommas(salary) +'</td></tr>';
      }
      return m;
    }          
    
    var totSalary = 0;
    var m = '<TABLE cellspacing=0 align=center width=95% class=pbTab><TBODY>';
	  m += '<TR><TD colspan=15><DIV class=pbStat>Knight Assign Methods - <input style="height:20px;font-size:9px;" type=button value="Add Default Skill" id="ptknight_def"><input style="height:20px;font-size:9px;" type=button value="Add Combat Skill" id="ptknight_com"></div></td></tr><TR><TD>&nbsp</td></tr>';
    for (var c=0; c<Cities.numCities; c++) {
      var cid = Cities.cities[c].id;
      m += '<TR><TD colspan=15><DIV class=pbStat>'+ Cities.cities[c].name +'</div></td></tr>\
          <TR class=ptwpad style="font-weight:bold" align=right><TD width=70>Role</td><TD width=140 align=center>Name</td><TD widith=70 align=center>Dismiss</td><TD width=40>Pol</td><TD width40>Com</td>\
          <TD width=40>Int</td><TD width=40>Res</td><TD width=90 align=center colspan=5>--- Unassigned ---</td><TD width=35>Level</td><td>Loyalty</td><TD width=40 align=right> Salary </td></tr>';
      totSalary = 0;
      var did = {}; 
      var row = 0;
      for (var i=0; i<KnightRoles.length; i++){
        var leader = Seed.leaders['city'+cid][KnightRoles[i][1]+'KnightId'];
        if (leader == 0) m += _dispKnight (i, null, c);
        else {
          m += _dispKnight (i, Seed.knights['city'+cid]['knt'+leader], c);
          did['knt'+leader] = true;
        }
      }
      var list = [];
      for (k in Seed.knights['city'+cid]) if (!did[k]) list.push (Seed.knights['city'+cid][k]); 
      list.sort (function (a,b){return parseInt(b.combat)-parseInt(a.combat)});
      for (i=0; i<list.length; i++) m += _dispKnight (null, list[i], c,cid);
      m += '<TR align=right><TD colspan=13><B>Total Salary:</b></td><TD>'+ addCommas(totSalary) +'</td></tr>';        
    }
    document.getElementById('ptknightdiv').innerHTML = m +'</tbody></table></div>';
	t.action = 0;
    document.getElementById('ptknight_com').addEventListener ('click', function (){
      t.action=1;
      t.show();
    }, false);
    document.getElementById('ptknight_def').addEventListener ('click', function (){
          t.action=2;
          t.show();
    }, false);
    t.displayTimer = setTimeout (t.show, 10000);
  },
  postDismissKnight:function(kid,cid){
  	var t = Tabs.Knights;
  	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.kid = kid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fireKnight.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) {
        	if (rslt.updateSeed){
        		delete Seed.knights["city" + cid]["knt" + kid];
        		if (rslt.updateSeed) {
                    unsafeWindow.update_seed(rslt.updateSeed)
                }
        		t.show();
        	}
        } 
      },
      onFailure: function () {},
    });
  },



  clickedAssignPoints : function (e, cid, kid, rid){
    var t = Tabs.Knights;
    clearTimeout (t.displayTimer);
      
    var knight = Seed.knights['city'+cid]['knt'+kid];
    if (knight.knightStatus == 10 && e!=null){
      var row = e.parentNode.parentNode;
      row.childNodes[7].innerHTML = 'Marching';
      return; 
    }
    sk = [];
    var unassigned = parseInt(Math.sqrt(parseInt(knight.experience)/75)) + 1  - parseInt(knight.skillPointsApplied);
	var overassigned = 0;
    for (var i=0; i<4; i++){
      sk[i] = parseInt(knight[KnightRoles[i][1]]);
      if (i == rid)
        sk[i] += unassigned;
      if(sk[i] > 300){
		overassigned = sk[i] - 300;
		sk[i] = 300;
	  }
    }
    unassigned = unassigned - overassigned;
	if (unassigned==0) return;
    if (e!=null) {
		var row = e.parentNode.parentNode;
		for (i=row.cells.length-1; i>=1; i--)
		  row.deleteCell (i);
		var newCell=row.insertCell(-1);
		newCell.colSpan = 12;
		newCell.align= 'left';
		newCell.style.padding='1px 5px 1px 10px';
		var div = document.createElement ('div');
		div.style.backgroundColor = '#ffffff';
		div.style.textAlign = 'center';
		div.style.border = '1px solid';
		div.style.width = '98%';
		div.style.whiteSpace = 'normal';
		newCell.appendChild (div);
		div.innerHTML = 'Assigning '+ unassigned +' skill points to '+ KnightRoles[rid][1] +' ... ';
	}
    t.postSkillPoints (cid, kid, sk[0], sk[1], sk[2], sk[3], function (r){t.postDone(r, div)});  
  },
  
  postDone : function (rslt, div){
    var t = Tabs.Knights;
    clearTimeout (t.displayTimer);
    if (rslt.ok){
      div.innerHTML += '<B>Done.</b>';
      t.displayTimer = setTimeout (t.show, 5000);
    } else {
      div.innerHTML += '<BR><SPAN class=boldRed>ERROR: '+ rslt.errorMsg +'</span>';
      t.displayTimer = setTimeout (t.show, 10000);
    }
  },
  
  postSkillPoints : function (cid, kid, pol, com, int, res, notify){  
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.kid = kid;
    params.p = pol;
    params.c = com;
    params.i = int;
    params.r = res;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/skillupKnight.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) {
          var knight = Seed.knights["city" + cid]["knt" + kid];
          var up = pol + com + int + res - knight.politics - knight.combat - knight.intelligence - knight.resourcefulness;
          knight.politics = pol;
          knight.combat = com;
          knight.intelligence = int;
          knight.resourcefulness = res;
          knight.skillPointsApplied = (parseInt(knight.skillPointsApplied) + up).toString();
        } 
        if (notify) notify (rslt);
      },
      onFailure: function () {
        if (notify) notify (rslt);
      },
    });
  },
};


/*************** WILDS TAB *********************/

var wildNames = {
   0: 'Bog',
  10: 'Grassland',
  11: 'Lake',
  20: 'Woods',
  30: 'Hills',
  40: 'Mountain',
  50: 'Plain',
};

var mercNames = {
  0: 'None',
  1: 'Novice',
  2: 'Intermediate',
  3: 'Veteran',
};

Tabs.Wilds = {
  tabOrder : 5,
  type : 'Tools',
  tabLabel : 'Wilds',

  myDiv : null,
  upGoldTimer : null,
  wildList : [],
  buildList : {},
  
  init : function (div){
    var t = Tabs.Wilds;
    t.myDiv = div;
    unsafeWindow.ptButMaxTraps = t.e_butMaxTraps;
    unsafeWindow.ptInpWildTraps = t.e_inpTraps;
    unsafeWindow.ptButWildSet = t.e_butWildSet;
    unsafeWindow.ptButAbandon = t.e_abandon;
    t.myDiv.innerHTML = '<DIV id=wildContent style="maxheight:700px; height:700px; overflow-y:auto">';
  },

  hide : function (){
    var t = Tabs.Wilds;
    clearTimeout (t.upGoldTimer);
  },
  
  show : function (){
    var t = Tabs.Wilds;
    clearTimeout (t.upGoldTimer);
    
    m = '<CENTER>'+ strButton20('RESET', 'id=ptwref') +'</center><TABLE class=pbTabPad cellspacing=0 cellpadding=0 align=center width=90%>';
    for (var c=0; c<Cities.numCities; c++){
      var city = Cities.cities[c];
      var cWilds = Seed.wilderness['city'+city.id];
      t.wildList[c] = []; 
      var castle = parseInt(Seed.buildings['city'+ city.id].pos0[1]);
      if(castle == 11) castle = 12;
      else if(castle == 12) castle = 14;
      var totw = 0;
      if (matTypeof(cWilds)=='object') for (var k in cWilds) ++totw;         
      m += '<TR><TD colspan=20><DIV class=pbStat><TABLE class=ptNoPad width=100%><TR><TD width=100></td><TD width=90% align=center>'+ city.name 
        +' &nbsp; ('+ city.x +','+ city.y +')</td><TD width=150 align=right>Wilds: '+ totw +' of '+ castle +' &nbsp; </TD></tr></table></div></td></tr>';
      var row = 0;  
      var sortem = [];
      if (matTypeof(cWilds) != 'array') {
        m += '<TR style="background-color:white; font-weight:bold;" align=right><TD align=left>Wild Type</td><TD></td><TD align=left>Coords</td><TD>Traps</td><TD align=center>Mercs</td><TD align=center>Abandon</td>';
        m += '<TD colspan=5>'+ htmlTitleLine(' CHANGE DEFENSES ') +'</td></tr>';
        for (var k in Seed.wilderness['city'+city.id])
          sortem.push (Seed.wilderness['city'+city.id][k]);
        sortem.sort (function (a,b){
          var x; if ((x = b.tileLevel-a.tileLevel)!=0) 
            return x; 
          return a.tileType-b.tileType;
        });
        for (i=0; i<sortem.length; i++){
          var wild = sortem[i]; 
          var wildDef = Seed.wildDef['t'+wild.tileId];
          if (wildDef==undefined || !wildDef)
            wildDef = {fort60Count:0, mercLevel:0};
          var maxTraps = parseInt(wild.tileLevel)*100;
          var maxBuild = maxTraps - parseInt(wildDef.fort60Count);
          t.wildList[c][i] = [wild.tileId, maxBuild];          
          //
          m += '<TR align=right'+ (row++%2?'':' class=ptOddrow') +'><TD align=left>'+ wildNames[wild.tileType] +'</td>\
            <TD>'+ wild.tileLevel +'</td><TD align=center><A onclick="pbGotoMap('+ wild.xCoord +','+ wild.yCoord +')">'+ wild.xCoord +','+ wild.yCoord +'</a></td>\
            <TD align=right><B>'+ wildDef.fort60Count +'</b></td><TD align=center><B>'+ mercNames[wildDef.mercLevel] +'</b></td><TD align=center>'+strButton14('Abandon', 'onclick="ptButAbandon('+wild.tileId+','+wild.xCoord+','+wild.yCoord+','+city.id+ ')" id=tileId_'+wild.tileId) + '</td>\
            <TD></td><TD align=left class=ptentry><B>Build Traps:</b> <INPUT onchange="ptInpWildTraps(this)" id=ptwt_'+ c +'_'+ i 
              + (maxBuild==0?' DISABLED ':'')+' style="margin:0px; padding:0px" type=text size=3 maxlength=4></td>'
          if (wildDef.fort60Count < maxTraps)
            m += '<TD class=ptentry style="padding:0px">'+ strButton14('Max', 'id=ptwx_'+ c +'_'+ i +' onclick="ptButMaxTraps(this)"') +'</td>';
          else
            m += '<TD class=ptentry></td>';
          m += '<TD class=ptentry> &nbsp; &nbsp; <B>Mercs:</b> ' + htmlSelector(mercNames, wildDef.mercLevel, 'id=ptwm_'+ c +'_'+ i) +' &nbsp; &nbsp; </td></tr>';
        }
        m += '<TR><TD colspan=6></td><TD></td><TD class=ptentry align=center colspan=3><TABLE><TR><TD width=40% align=left>Cost: <SPAN id=ptwgc_'+ c +'>0</span></td>\
            <TD width=10%>'+ strButton20("SET DEFENSES", 'onclick="ptButWildSet('+ c +')"') +'<TD width=40% align=right>Gold: <SPAN id=ptwgt_'+ c +'>0</span></td></td></tr></table></td></tr>';
      } else {
        m+= '<TR><TD colspan=9> &nbsp; </td></tr>';
      }         
    }
    document.getElementById('wildContent').innerHTML = m + '</table></div><BR>';
    document.getElementById('ptwref').addEventListener ('click', t.show, false);
    t.updateGold ();
  },
  
  e_abandon:function(tileId,xCoord,yCoord,cityId){
  	var t = Tabs.Wilds;
  	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.tid = tileId;
    params.x = xCoord;
    params.y = yCoord;
    params.cid = cityId; 
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/abandonWilderness.php" + unsafeWindow.g_ajaxsuffix, {
    	method: "post",
    	parameters: params,
    	onSuccess: function (rslt) {
    		if (rslt.ok){
   				delete Seed.wilderness["city"+cityId]["t" + tileId];
   				t.show();
    			if (rslt.updateSeed) unsafeWindow.update_seed(rslt.updateSeed);
    			
    		}
    	},  
    	onFailure: function () {},
    });
  },

  e_butWildSet : function (c){
    var t = Tabs.Wilds;
    var totTraps = 0;  
    var cid = Cities.cities[c].id;
    t.buildList = {cityId:cid, list:[]};      
    for (var w=0; w<t.wildList[c].length; w++){
      var wild = Seed.wilderness['city'+cid]['t'+t.wildList[c][w][0]]; 
      var wildDef = Seed.wildDef['t'+t.wildList[c][w][0]];
// TODO: Seed.wildDef is null if just aquired 
if (wildDef==undefined || !wildDef)
  wildDef = {fort60Count:0, mercLevel:0};
    
      var numTraps = parseInt(document.getElementById('ptwt_'+ c +'_'+ w).value, 10);
      if (isNaN(numTraps))
        numTraps = 0;
      totTraps += numTraps;
      if (numTraps > 0)
        t.buildList.list.push (['T', wild.tileId, numTraps]);
      var mercId =document.getElementById('ptwm_'+ c +'_'+ w).value; 
      if (wildDef.mercLevel != mercId)
        t.buildList.list.push (['M', wild.tileId, mercId, wildDef.mercLevel]);
    }

    var totCost = totTraps * 200; 
    if (totCost > parseInt(Seed.citystats['city'+cid].gold[0])){
      document.getElementById('ptwgc_'+ c).innerHTML = '<SPAN class=boldRed>'+ addCommasInt(totCost) +'</span>';
      return; 
    }
    if (t.buildList.list.length == 0)
      return;
    t.setCurtain (true);
    var popDiv = t.setPopup (true);
    popDiv.innerHTML = '<TABLE width=100% height=100%><TR><TD>\
          <DIV>Setting Wilderness Defenses</div>\
          <DIV id=ptWildBuildDiv style="padding:10px; height:225px; max-height:225px; overflow-y:auto"></div>\
          </td></tr><TR><TD align=center>'+ strButton20('CANCEL', 'id=ptWildCancel') +'</td></tr></table>';
    document.getElementById('ptWildCancel').addEventListener('click', t.e_buildCancel, false);
    t.processQue(null);  
  },
  
  e_buildCancel : function (){
    var t = Tabs.Wilds;
    t.setCurtain(false);
    t.setPopup(false);
    t.show();
  },
  
  processQue : function (errMsg){
    var t = Tabs.Wilds;
    var what = t.buildList.list.shift();
    var div = document.getElementById('ptWildBuildDiv');
    if (what==null || errMsg){
      if (errMsg)
        div.innerHTML += '<BR><SPAN style="white-space:normal;" class=boldRed>ERROR: '+ errMsg +'</span>';
      else
        div.innerHTML += 'Done.<BR>';
      document.getElementById('ptWildCancel').firstChild.innerHTML = 'CLOSE'; 
      return;
    }
    if (div.innerHTML != '')
      div.innerHTML += 'Done.<BR>';
    var wild = Seed.wilderness['city'+ t.buildList.cityId]['t'+what[1]];
    if (what[0] == 'T'){
      div.innerHTML += 'Building '+ what[2] +' traps for '+ Cities.byID[t.buildList.cityId].name +'\'s wilderness at '+ wild.xCoord +','+ wild.yCoord +' ... ';
      t.postBuyTraps (t.buildList.cityId, what[1], what[2], t.processQue);
    } else {
      div.innerHTML += 'Setting Mercenaries to '+ mercNames[what[2]] +' for '+ Cities.byID[t.buildList.cityId].name +'\'s wilderness at '+ wild.xCoord +','+ wild.yCoord +' ... ';
      t.postHireMercs (t.buildList.cityId, what[1], what[2], what[3], t.processQue);
    }
  },
  
  setPopup : function (onoff){
    var t = Tabs.Wilds;
    if (onoff){
      var div = document.createElement('div');
      div.id = 'ptWildPop';
      div.style.backgroundColor = '#fff';
      div.style.zindex = mainPop.div.zIndex+2;
      div.style.opacity = '1';
      div.style.border = '3px outset red';
      div.style.width = '550px';
      div.style.height = '300px';
      div.style.display = 'block';
      div.style.position = 'absolute';
      div.style.top = '100px';
      div.style.left = '100px';
      t.myDiv.appendChild (div);
      return div;
    } else {
      t.myDiv.removeChild (document.getElementById('ptWildPop'));
    }
  },

  setCurtain : function (onoff){
    var t = Tabs.Wilds;
    if (onoff){
      var off = getAbsoluteOffsets (t.myDiv);
      var curtain = document.createElement('div');
      curtain.id = 'ptWildCurtain';
      curtain.style.zindex = mainPop.div.zIndex+1;
      curtain.style.backgroundColor = "#000000";
      curtain.style.opacity = '0.5';
      curtain.style.width = t.myDiv.clientWidth +'px';
      curtain.style.height = t.myDiv.clientHeight +'px';
      curtain.style.display = 'block';
      curtain.style.position = 'absolute';
      curtain.style.top = off.top + 'px';
      curtain.style.left = off.left + 'px';
      t.myDiv.appendChild (curtain);
    } else {
      t.myDiv.removeChild (document.getElementById('ptWildCurtain'));
    }
  },
  
  e_butMaxTraps : function (e){
    var t = Tabs.Wilds;
    var c = e.id.substr(5,1);
    var w = e.id.substr(7);
    var inp = document.getElementById('ptwt_'+ c +'_'+ w);
    inp.value = t.wildList[c][w][1];
    t.e_inpTraps (inp);
  },
  
  e_inpTraps : function (e){
    var t = Tabs.Wilds;
    var c = e.id.substr(5,1);
    var w = e.id.substr (7);
    var tot = 0;
    for (var i=0; i<t.wildList[c].length; i++) {
      var val = parseInt(document.getElementById('ptwt_'+ c +'_'+ i).value, 10);
      if (isNaN(val))
        val = 0;
      tot += val;
    }  
    document.getElementById('ptwgc_'+ c).innerHTML = addCommasInt(tot * 200);
    if (isNaN(e.value) || e.value<0 || e.value>t.wildList[c][w][1]){
      e.value = '';
      e.style.backgroundColor = '#ffaaaa'; 
    } else
      e.style.backgroundColor = null; 
  },

  updateGold : function (){
    var t = Tabs.Wilds;
    for (var c=0; c<Cities.numCities; c++){
      var e = document.getElementById('ptwgt_'+ c +'');
      if (e)
        e.innerHTML = addCommasInt(Seed.citystats['city'+Cities.cities[c].id].gold[0]);
    }
    t.upGoldTimer = setTimeout (t.updateGold, 2000);
  },
  
  postBuyTraps : function (cid, tid, quant, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.tid = tid;
    params.quant = quant;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/buyWildTraps.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok){
          if (!Seed.wildDef["t"+ tid])
            Seed.wildDef["t"+ tid] = {tileId:tid, fort60Count:0, mercLevel:0};
          Seed.wildDef["t"+ tid].fort60Count = parseInt(Seed.wildDef["t"+ tid].fort60Count) + parseInt(quant);
        }  
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },

  postHireMercs : function (cid, tid, newLevel, oldLevel, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.tid = tid;
    params.lv = newLevel;
    params.olv = oldLevel;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/hireWildMerc.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok){
          if (!Seed.wildDef["t"+ tid]) Seed.wildDef["t"+ tid] = {tileId:tid, fort60Count:0, mercLevel:0};
          Seed.wildDef["t"+ tid].mercLevel = newLevel;
        }
        if (notify) notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify) notify ('AJAX ERROR');
      },
    });
  },
          
}    
 

/********************** Tournament Tab *******************************************/
Tabs.Tournament = {
  tabOrder : 6,
  type: 'Tools',
  myDiv:null,
  displayTimer : null,
 
  init : function (div){Tabs.Tournament.myDiv = div;},
  hide : function (){clearTimeout (Tabs.Tournament.displayTimer);},
  getContent : function (){return Tabs.Tournament.myDiv;},
  show : function () {
    var t = Tabs.Tournament;
    t.myDiv.style.overflowY = 'auto';
    t.myDiv.style.maxHeight = '650px';
    clearTimeout (t.displayTimer);
    t.myDiv.innerHTML = "<div class='tourny_modal_upsell'></div>";
    var mhtl = "<DIV class=pbStat>POPULATION AND PRODUCTION INFORMATION</div><table width=100% class=pdxTab><tr><td colspan=8>&nbsp;</td></tr><tr><td></td>";
    for(var i=0; i<Cities.numCities; i++) {
     mhtl += "<TD align=center valign=bottom width=60px><B>" + Cities.cities[i].name + "</B></TD>";
    }
    mhtl += "</tr><tr><td><img height=18 src=http://koc-power-pdx.googlecode.com/svn/trunk/img/troops/unit_2_50.jpg?6545 title=Militiaman> Militiaman/h</td>";
    var temps=[];
    for(var i=0; i<Cities.numCities; i++) {
     temps[i]=((Cities.cities[i]['Troop2Time'] > 0)?(3600 / Cities.cities[i]['Troop2Time']):0);
     mhtl += "<td>" + addCommas(parseInt(temps[i])) +"</td>";
    }
      mhtl += "</tr><tr><td><img height=18 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/population_40.png title=Population> Population/h</td>";
    var pop=[];
    for(var i=0; i<Cities.numCities; i++) {
     cityID = 'city'+ Cities.cities[i].id;
     pop[i] =  parseInt(Seed.citystats[cityID]["pop"][1]) / 2;
     mhtl += "<td>" + addCommas(parseInt(pop[i])) +"</td>";
    }
    mhtl += "</tr><tr><td><b>Difference</b></td>";
    var diff=0;
    for(var i=0; i<Cities.numCities; i++) {
     diff = parseInt(pop[i] - temps[i]);
     var couleur=" style='font-color:green' ";
     if (diff<0) couleur=" style='background-color:red' ";
     mhtl += "<td "+couleur+"><b>" + addCommas(parseInt(diff)) +"</b></td>";
    }
    
     mhtl += "</tr><tr><td><img height=18 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/happiness.png title=happiness> happiness</td>";
     for(var i=0; i<Cities.numCities; i++) {
     cityID = 'city'+ Cities.cities[i].id;
     var bon = parseInt(Seed.citystats[cityID]["pop"][2]); 
     var bonc = "red";
     if (bon>99) bonc="green";
     mhtl += "<td style='background-color:"+bonc+"'><center><b>"+bon+"</td>";
    }
    var now = unixTime();
    mhtl += "</tr><tr><td><b>Queue</b></td>";
      for(var i=0; i<Cities.numCities; i++) {
       cityID = 'city'+ Cities.cities[i].id;
       var totTime = 0;
       var q = Seed.queue_unt[cityID]; 
       if (q!=null && q.length>0)
           totTime = q[q.length-1][3] - now;
       if (totTime < 0) totTime = 0;
       if (totTime < 3600)
        var bonc="style='background-color:red'";
       else
        var bonc="";
       mhtl += "<td "+bonc+"><center><b>"+timestr(totTime)+"</td>";
      }
      
    mhtl += "</tr></table><br>";
    t.myDiv.innerHTML += mhtl;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.format=2;
    params.tournyPos=0;
    new AjaxRequest(unsafeWindow.g_ajaxpath+"ajax/getLeaderboard.php"+unsafeWindow.g_ajaxsuffix, {  method:"post",  parameters:params,
    
    onSuccess:function(transport){
     var rslt=eval("("+transport.responseText+")");
     if(rslt.ok){
     
      if(!rslt.data){
       
    t.myDiv.innerHTML +="<div class=pbStat>TOURNAMENT CHECK</div><div class='tourny_modal_upsell'><br><center><b>"+unsafeWindow.g_js_strings.modal_tourny_changetab.notourny+"</b></center></div>";
      
      
      }else{ //  rslt.data
       var tournyhtml=new Array();
       
       if(rslt.name){
        tournyhtml.push("<div class=pbStat><center>"+rslt.name.replace('The Tournament of Might','THE TOURNAMENT OF MIGHT')+"</center></div>")
       }  else{
        tournyhtml.push("<div class='tournymodaltitle'><center>"+unsafeWindow.g_js_strings.commonstr.tournament+"</div>")
       }
       tournyhtml.push("<div>");
       
       
       
       if(rslt.startdate&&rslt.enddate){
                var startTime=rslt.startdate;
                var endTime=rslt.enddate;
                var now=parseInt(new Date().getTime()/1000);
                tournyhtml.push("<table width=100% align=center class=pbTab><tr bgcolor=#FE8888><td width=40%><b>Starts</td><td width=40%><b>Ends</td><td width=20%><b>Ends</td></tr>");
                dt = new Date ();
                    dt.setTime (startTime * 1000);
                    dtf = new Date ();
                    dtf.setTime (endTime * 1000);
                   
                    var restant = endTime - now; 
                    
               
               tournyhtml.push("<tr><td>");
                 tournyhtml.push("" + dt.toLocaleDateString() + " - "+ dt.toLocaleTimeString());
                tournyhtml.push("</td><td>");
                tournyhtml.push("" + dtf.toLocaleDateString()+ " - "+ dtf.toLocaleTimeString());
                tournyhtml.push("</td><td>"+timestr(restant,1)+"</td></tr></table>");
             tournyhtml.push("<br>");
     
     }
     
  
     tournyhtml.push("<center><table class='tourny_list_table' cellpadding='0' cellspacing='0' border='0' width=90% style='margin:5px'>");
     tournyhtml.push("<thead>");
     tournyhtml.push("<tr>");
     if(rslt.type==24){
      tournyhtml.push("<td class='rankcol' style='background-color:red'>");
      tournyhtml.push("<div><input type=button id='BOTournoiPM' value='-'>&nbsp;"+unsafeWindow.g_js_strings.commonstr.ranking+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>Chancellor</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.alliance+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>"+unsafeWindow.g_js_strings.modal_tourny_changetab.mightgained+"</div>");
      tournyhtml.push("</td  style='background-color:red'>");
      tournyhtml.push("<td  style='background-color:red'> ");
      tournyhtml.push("<div>"+unsafeWindow.g_js_strings.modal_tourny_changetab.rewardperplayer+"</div>");
      tournyhtml.push("</td>")
      }else{
            tournyhtml.push("<td  class='rankcol' style='background-color:red'>");
      tournyhtml.push("<div><input type=button id='BOTournoiPM' value='-'>&nbsp;"+unsafeWindow.g_js_strings.commonstr.ranking+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>Player</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.alliance+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>"+rslt.contestcategory+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td  style='background-color:red'>");
      tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.reward+"</div>");
      tournyhtml.push("</td>")
     }
     tournyhtml.push("</tr>");
     tournyhtml.push("</thead>");
     tournyhtml.push("</tbody>");
     var nb=rslt.data.length;
     var votrepuissance = 0;
     for(var i=0;i<rslt.data.length;i++){
      var row=rslt.data[i];
      if(rslt.type==24){ // Tournament
       if (getMyAlliance()[1] == row.alliance) {
        votrepuissance=row.contestValue;
        break;
       }
      } else {
       if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
        votrepuissance=row.contestValue;
        break;
       }  
      }
     }
     for(var i=0;i< Options.TournoiLigne;i++){
      var row=rslt.data[i];
      var rewardString=row.itemCount+" ";
      if(row.itemType==0){
       rewardString+=unsafeWindow.g_js_strings.commonstr.gems;
      }else{
       rewardString+=unsafeWindow.itemlist["i"+row.itemType].name;
      }
      var couleur="";
      if(rslt.type==24){ //Alliance Tournament
       if (getMyAlliance()[1] == row.alliance) {
        couleur=" style='background-color:#FF0000' ";
       }
      }else{
       if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
        couleur=" style='background-color:#FF0000' ";
       }
      }
      if(i%2==1){
       tournyhtml.push("<tr>")
      }else{
       tournyhtml.push("<tr class='stripe'>")
      }
      tournyhtml.push("<td class='rankcol' "+couleur+">");
      tournyhtml.push("<div><b>"+row.ranking+"</b></div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td "+couleur+">");
      tournyhtml.push("<div>"+row.name+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td "+couleur+">");
      tournyhtml.push("<div>"+(row.alliance||"----")+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td "+couleur+">");
      tournyhtml.push("<div>"+addCommas(row.contestValue));
      if (votrepuissance>0) {
        var ecartavecvous = parseInt(row.contestValue - votrepuissance);
        if (ecartavecvous>0) {
         tournyhtml.push("&nbsp;(+ " + addCommas(ecartavecvous) +")");
        } 
        if (ecartavecvous<0) {
         tournyhtml.push("&nbsp;(" + addCommas(ecartavecvous) +")");
        }
      }
      tournyhtml.push("</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("<td "+couleur+">");
      tournyhtml.push("<div>"+rewardString+"</div>");
      tournyhtml.push("</td>");
      tournyhtml.push("</tr>")
     } // fin du for
  
        if(rslt.type!=24){

      for(var i= Options.TournoiLigne;i<rslt.data.length;i++){
          var row=rslt.data[i];
       
          if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
            var rewardString=row.itemCount+" ";
                if(row.itemType==0){
                 rewardString+=unsafeWindow.g_js_strings.commonstr.gems;
                }else{
                 rewardString+=unsafeWindow.itemlist["i"+row.itemType].name;
                }
                tournyhtml.push("<tr class='stripe' >")
                tournyhtml.push("<td class='rankcol' style='background-color:#FF0000'>");
                tournyhtml.push("<div><b>"+row.ranking+"</b></div>");
                tournyhtml.push("</td>");
                tournyhtml.push("<td style='background-color:#FF0000'>");
                tournyhtml.push("<div>"+row.name+"</div>");
                tournyhtml.push("</td>");
                tournyhtml.push("<td style='background-color:#FF0000'>");
                tournyhtml.push("<div>"+(row.alliance||"----")+"</div>");
                tournyhtml.push("</td>");
                tournyhtml.push("<td style='background-color:#FF0000'>");
                tournyhtml.push("<div>"+addCommas(row.contestValue)+"</div>");
                tournyhtml.push("</td>");
                tournyhtml.push("<td style='background-color:#FF0000'>");
                tournyhtml  .push("<div>"+rewardString+"</div>");
                tournyhtml.push("</td>");
                  tournyhtml.push("</tr>")
         }    
     }
     }
     tournyhtml.push("</tbody>");
     tournyhtml.push("</table>");
      tournyhtml.push("</div>");
      t.myDiv.innerHTML += tournyhtml.join("");      
           document.getElementById('BOTournoiPM').addEventListener ('click', function() { 
            var lg=rslt.data.length;
            if (rslt.type!=24) lg=25;
            t.plusmoins(lg);
           }, false);      
           
        if ((Options.TournoiLigne==5 && rslt.type!=24) || (Options.TournoiLigne==5 && rslt.type==24)) {
          document.getElementById('BOTournoiPM').value="Maximize";
      } else {
          document.getElementById('BOTournoiPM').value="Minimize";           
        }
          } // fin rslt.data 
         } else {
            t.myDiv.innerHTML = "<div class='tourny_modal_upsell'><center>No Info</div>";
         }
       }, onFailure:function()  {
         t.myDiv.innerHTML = "<div class='tourny_modal_upsell'><center>No Info</div>";
       }
   });
   t.displayTimer = setTimeout (t.show, 240000);       
  },
  plusmoins: function(lg) {
   var t = Tabs.Tournament;
   if (document.getElementById('BOTournoiPM').value=="Maximize") {
     document.getElementById('BOTournoiPM').value="Minimize";
     Options.TournoiLigne = lg;
   } else {
     document.getElementById('BOTournoiPM').value="Maximize";
     Options.TournoiLigne = 5;
   }
   saveOptions();
   clearTimeout (t.displayTimer);
   t.show();
  },  

}


/*********************************** Alliance TAB ***********************************/
Tabs.Alliance = {
  tabOrder : 7,
  type : 'Tools',
  tabLabel : unsafeWindow.g_js_strings.commonstr.alliance,
  myDiv : null,
  alliancemembers:[],
  number:0,
  totalmembers:0,
  error:false,
  sortType: 1,
  sortBy: 'Name',
  CardQuality:{0:"Simple",1:"Common",2:"Uncommon",3:"Rare",4:"Epic",5:"Wondrous"},
  
  init : function (div){    
    var t = Tabs.Alliance;      
    t.myDiv = div;
    t.totalmembers=0;
    t.alliancemembers=[];   
    unsafeWindow.getdetails = t.getMemberDetails;
    unsafeWindow.GetTRinfo = t.GetTRinfo;  
    var m =  '<DIV class=pbStat>ALLIANCE FUNCTIONS</div>';    
    m +='<TABLE class=pbTab><TD width=200px>List Alliance Members</td><TD>Sort by: '+ htmlSelector({Name:'Name',Might:'Might',glory:'Glory',Cities:'Cities',Position:'Position',dip:'Days in Position',uid:'User Id',fbuid:'Facebook id'},null,'id=searchAlli') +'</td>';
    m += '<TD><INPUT id=alList type=submit class=pbButton value="List"></td>';
    m += '<TD id=progress></td>';
    m += '<TR><TD width=200px>Show alliance diplomaties</td><TD><INPUT id=aldiplo type=submit class=pbButton value="List diplomaties"></td></tr>';
    m += '<TR><TD><SPAN id=DIVsend></span></td></tr></table>'; 
    m+='<DIV class=pbStat>OVERVIEW</div><DIV style="max-height:500px;overflow:auto" id=alOverviewTab></div><BR>';
      
    t.myDiv.innerHTML = m;    
    document.getElementById('alList').addEventListener('click', function(){
      if (!t.searching){
        t.totalmembers=0;
        t.alliancemembers=[]; 
        document.getElementById('alOverviewTab').innerHTML ="";
        document.getElementById('progress').innerHTML ="";
        document.getElementById('progress').innerHTML = unsafeWindow.g_js_strings.commonstr.loadingddd;
        document.getElementById('alList').disabled = true;
        t.error=false;
        t.fetchAllianceMemberFirstPage();
    } 
    }, false);
    
    document.getElementById('searchAlli').addEventListener('click', function(){
        if (t.alliancemembers!="") {
          document.getElementById('alOverviewTab').innerHTML ="";
          t.paintMembers(); 
        }
    }, false);
    document.getElementById('aldiplo').addEventListener('click', function(){t.paintDiplomacy();}, false);      
  },
  
  paintMembers: function(){
  var t = Tabs.Alliance;
  if(document.getElementById('searchAlli').value == t.sortBy)t.sortType *= -1;
   else t.sortType = 1; 
  t.sortBy = document.getElementById('searchAlli').value;
  var sortmembers = t.alliancemembers.sort(function(a, b){
  var sortA = a[t.sortBy],sortB = b[t.sortBy];
     if(t.sortType > 0){
       if(typeof(sortA) == 'number' && typeof(sortB) == 'number') return sortA - sortB;
        else return sortA.localeCompare(sortB);  
     } else {
       if(typeof(sortA) == 'number' && typeof(sortB) == 'number') return sortB - sortA;
        else return sortB.localeCompare(sortA);  
     }
  });
  document.getElementById('alOverviewTab').innerHTML = '<TABLE id=alMembers width=90%><TR align="center"></tr></table>';;
  for (var y = (sortmembers.length-1); y >=0; y--) t._addTab(sortmembers[y].Name,sortmembers[y].Might,sortmembers[y].LastLogin,sortmembers[y].Position,sortmembers[y].dip,sortmembers[y].uid,sortmembers[y].fbuid,sortmembers[y].Cities,sortmembers[y].glory,sortmembers[y].dateJoined);
   t._addTabHeader();
 },

  MsgPopUp: function(){
    var t = Tabs.Alliance;
    var To = [];
    var element_class = document.getElementsByClassName('AllianceMSG'); 
    for (k=0;k<element_class.length;k++) if (element_class[k].checked) To.push(element_class[k].id.substr(4));
    if (To.length ==0) {alert('Select members...');return;}
    document.getElementById('alOverviewTab').innerHTML ="";
    document.getElementById('DIVsend').innerHTML = "";
    var m = '<TABLE class=pbTab><BR><INPUT id=SendMail type=submit class=pbButton value="Send Message"><BR><DIV id=MSGlist></div>';
    m+= '<BR><BR>Subject:&nbsp<input type=text id=MailSubject><BR><BR>';
    m += '<textarea type="text" id="MailContent" rows=20 cols=80></textarea></table>';
    document.getElementById('alOverviewTab').innerHTML = m;
    var mm = 'Receipents: <BR><TABLE border="1" width=100%><TR>';
    for (var i=0;i<To.length;i++) {
      if (i%10==0) mm+='</tr><TR>';
      mm += '<TD>' + To[i] +'</td>';
    }
    mm += '</tr></table>';  
    document.getElementById('MSGlist').innerHTML = mm;
    document.getElementById("SendMail").addEventListener ('click', function (){t.MSGLoop(To,document.getElementById('MailSubject').value,document.getElementById('MailContent').value)}, false);
  },

  MSGLoop: function (To,Subject,Content){
    var t = Tabs.Alliance;
    document.getElementById('alOverviewTab').innerHTML = "<U>Sending messages:</u><BR><BR>";
    for (var i=0;i<To.length;i++){
      document.getElementById('alOverviewTab').innerHTML += "<BR>" + To[i] + ': ' + '<SPAN id="Send_'+To[i]+'"></span>';
      setTimeout(t.SendMSG,(i*1000),To[i],Subject,Content);
    }

  },

  SendMSG: function(To,Subject,Content){
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.emailTo = To;
      params.subject = Subject;
      params.message = Content;
      params.requestType = "COMPOSED_MAIL";
      new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (message) {
              var rslt = eval("(" + message.responseText + ")");
              if (rslt.ok) document.getElementById('Send_'+To).innerHTML = '<FONT color=green>Send</font>';
               else t.SendMSG(To,Subject,Content);
          },
          onFailure: function () {},
      });
  },

    _addTab: function(Name,Might,LastLogin,Position,dip,uid,fbuid,Cities,glory,dateJoined){
    var t = Tabs.Alliance;
    var avatar = "https://graph.facebook.com/"+fbuid+"/picture";
    var row = document.getElementById('alMembers').insertRow(0);
    row.vAlign = 'top';
    row.insertCell(0).innerHTML = '<INPUT class="AllianceMSG" id="MSG_'+Name+'" type=checkbox unchecked=true>';
    row.insertCell(1).innerHTML ='<A target="_tab" href="http://www.facebook.com/profile.php?id='+ fbuid +'"><img width=25 src="'+ avatar +'"></a>';
    row.insertCell(2).innerHTML = Name;
    var cell2 = row.insertCell(3); 
    cell2.width = "60" ;
    cell2.align = "right" ;
    cell2.vAlign = "top";
    cell2.innerHTML = addCommas(Might);
    var cell2 = row.insertCell(4);
    cell2.width = "60" ;
    cell2.align = "right" ;
    cell2.vAlign = "top";
    cell2.innerHTML = addCommas(glory);
    var cell2 = row.insertCell(5);
    cell2.width = "60" ;
    cell2.align = "center" ;
    cell2.vAlign = "top";
    cell2.innerHTML = Cities;
    row.insertCell(6).innerHTML = officerId2String (Position);
    row.insertCell(7).innerHTML = dip;
    row.insertCell(8).innerHTML = LastLogin;
    row.insertCell(9).innerHTML = dateJoined;
    row.insertCell(10).innerHTML ='<A onclick="GetTRinfo('+ uid +')">View</a>'; 
    },
          
    _addTabHeader: function() {
    var t = Tabs.Alliance;
    var row = document.getElementById('alMembers').insertRow(0);
    row.vAlign = 'top';
    row.insertCell(0).innerHTML = "&nbsp";
    row.insertCell(1).innerHTML = "<u><b>FB</b></u>";
    row.insertCell(2).innerHTML = "<u><b>Name</b></u>";
    row.insertCell(3).innerHTML = "<u><b>Might</b></u>";

    row.insertCell(4).innerHTML = "<u><b>Glory</b></u>";
    row.insertCell(5).innerHTML = "<u><b>Cities</b></u>";
    row.insertCell(6).innerHTML = "<u><b>Position</b></u>";
    row.insertCell(7).innerHTML = "<u><b>DIP</b></u>";
    row.insertCell(8).innerHTML = "<u><b>Last Login</b></u>";
    row.insertCell(9).innerHTML = "<u><b>Joined</b></u>";
    row.insertCell(10).innerHTML = "<u><b>TR</b></u>";
    },


    GetTRinfo: function(uid){
      var t = Tabs.Alliance;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
      params.action = 'getEquipped';
      params.playerId = uid;    
      new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          loading: true,
          onSuccess: function (transport) {
              var rslt = eval("(" + transport.responseText + ")");
                  if(rslt.ok) {
                    msg ='<TABLE width=100% height=0% class=pbTab><TR>';
              for (i=1;i<=7;i++){
                if (i%2==0) msg+='</tr><TR>';
                msg+='<TD><DIV id=DIV_TR_'+ i +'></div></td>';  
              }
            msg+="</tr></table>"
                    var pop = new pbPopup ('showTR', 0, 0, 700, 500, true);
              pop.centerMe (mainPop.getMainDiv());  
              pop.getMainDiv().innerHTML = msg;
              pop.getTopDiv().innerHTML = '<CENTER><B>Throne Room</b></center>';
              pop.show (true);
              for (var i=1;i<=rslt.items.length;i++) {
                      document.getElementById('DIV_TR_'+i).innerHTML = t.paintEquipInfo(rslt.items[i-1]);
                    }
                  }
          },
          onFailure: function () {return;},
      });
    },

    paintEquipInfo : function (y){
    var t = Tabs.Alliance;
    var m="";
    var color = "black";
    var id =0;
    var tier=0;
    var Current=0;
    if (parseInt(y.unique) > 0) {
      var Name = unsafeWindow.g_js_strings.throneRoom["unique_" + y.type + y.unique];
      var icon = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/' + y.faction + '/' + y.faction + '_'+ y.type +'_unique_normal_'+ y.unique+'.png';
    } else {
      var Name = t.CardQuality[y.quality] + ' ' + y.type + " " + unsafeWindow.g_js_strings.commonstr.of + " " + unsafeWindow.cm.ThroneController.getEffectSuffix(y["effects"]["slot5"]["id"]) + " +" + y.level;
      var icon = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/' + y.faction + '/' + y.faction + '_'+ y.type +'_normal_1_'+ y.quality+'.png';
    }
    m='<TABLE width=80% height=0% align="center" class=ThroneEQ style="background: transparent url('+ icon +') bottom right no-repeat; background-color:#FFFFE3;">';
    switch(parseInt(y["quality"])){
      case 1:color="grey";break;
      case 2:color="white";break;
      case 3:color="green";break;
      case 4:color="blue";break;
      case 5:color="purple";break;
      default:break;
    }
      m+='<TR><TD style="background-color:#D5C795"><FONT color='+ color +'><B>' + Name + '</b></font></td></tr>';
    for (i=1;i<=5;i++) {
        id = y["effects"]["slot"+i]["id"];
        tier = parseInt(y["effects"]["slot"+i]["tier"]);
        level = y.level;
        p = unsafeWindow.cm.thronestats.tiers[id][tier];
        Current = p.base + ((level * level + level) * p.growth * 0.5);
        var quality = parseInt(y["quality"]);
      if (i<=quality) m+='<TR><TD><FONT color=black>' + Math.round(Current*100)/100 + "% " + unsafeWindow.cm.thronestats["effects"][id]["1"] + '</font></td></tr>';
      else m+='<TR><TD><FONT color=grey>' + Math.round(Current*100)/100 + "% " + unsafeWindow.cm.thronestats["effects"][id]["1"] + '</font></td></tr>';
    }
    m+="</table>"
    return m;
  },
    
    
    paintDiplomacy : function () {
      document.getElementById('alOverviewTab').innerHTML ="";
      document.getElementById('progress').innerHTML ="";
      var m= '<TABLE class=pbTab width=300px><TR><TD colspan=4 style="background: #33CC66;" align=center><B>Friendly: </b></td></tr>';
      if (Seed.allianceDiplomacies['friendly'] == null) m+='<TR><TD>No Friendlies found...</td>';
      else m += '<TABLE class=pbTab width=300px><TR><TD width=200px>Alliance Name</td><TD align=center>Members</td></tr>';
      for (k in Seed.allianceDiplomacies['friendly']){
        m+='<TR><TD>'+Seed.allianceDiplomacies['friendly'][k]['allianceName']+'</td>';
        m+='<TD align=center>'+Seed.allianceDiplomacies['friendly'][k]['membersCount']+'</td>';
      }
      m+='<TR></tr></table><TABLE class=pbTab width=300px>';
      m+= '<TR><TD colspan=4 style="background: #CC0033;" align=center><B>Hostile: </b></td></tr>';
      if (Seed.allianceDiplomacies['hostile'] == null) m+='<TR><TD>No Hostiles found...</td>';
      else m += '<TABLE class=pbTab width=300px><TR><TD width=200px>Alliance Name</td><TD align=center>Members</td></tr>';
      for (k in Seed.allianceDiplomacies["hostile"]){
        m+='<TR><TD>'+Seed.allianceDiplomacies["hostile"][k]['allianceName']+'</td>';
        m+='<TD align=center>'+Seed.allianceDiplomacies["hostile"][k]['membersCount']+'</td>';
      }
      m+='<TR></tr></table><TABLE class=pbTab width=300px>';
      m+= '<TR><TD colspan=4 style="background: #FF6633;" align=center><B>Friendly towards us: </b></td></tr>';
      if (Seed.allianceDiplomacies['friendlyToYou'] == null) m+='<TR><TD>No Friendlies towards us found...</td>';
      else m += '<TABLE class=pbTab width=300px><TR><TD width=200px>Alliance Name</td><TD align=center>Members</td></tr>';
      for (k in Seed.allianceDiplomacies["friendlyToYou"]){
        m+='<TR><TD>'+Seed.allianceDiplomacies["friendlyToYou"][k]['allianceName']+'</td>';
        m+='<TD align=center>'+Seed.allianceDiplomacies["friendlyToYou"][k]['membersCount']+'</td>';
      }
      m+='<TR></tr></table>';
      document.getElementById('alOverviewTab').innerHTML = m;
    },
    
  
    fetchAllianceMemberFirstPage : function () {
      var t = Tabs.Alliance;
      document.getElementById('alList').disabled = true;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      var Members = 0;

      params.pageNo = 1;
      params.pf = 0;
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (transport) {
        var info = eval("(" + transport.responseText + ")");
        if (info.ok) {
          document.getElementById('progress').innerHTML='Searching: <PROGRESS id=searchProgress value="1" max="'+ info.noOfPages +'"></progress>';
          Members = info.memberCount;
            for (var k in info["memberInfo"]){
              if ( info["memberInfo"][k]["might"] != undefined && !t.error){  
                  t.alliancemembers.push ({
                    Name: info["memberInfo"][k]["name"],
                    Might: parseInt(info["memberInfo"][k]["might"]),
                    Cities: parseInt(info["memberInfo"][k]["cities"]),
                    Position : parseInt(info["memberInfo"][k]["positionType"]),
                    dip : parseInt(info["memberInfo"][k]["daysInPosition"]),
                    LastLogin : info["memberInfo"][k]["lastLogin"],
                    uid : parseInt(info["memberInfo"][k]["userId"]),
                    fbuid : parseInt(info["memberInfo"][k]["fbuid"]),
                 	avatarurl : info["memberInfo"][k]["avatarurl"],
                 	glory : parseInt(info["memberInfo"][k]["glory"]),
                 	dateJoined : info["memberInfo"][k]["dateJoined"],                 
                  });
                }
               document.getElementById('alOverviewTab').innerHTML ="";
               t.paintMembers();
          }
          for (var i=2;i<=info.noOfPages;i++) setTimeout(t.fetchAllianceMemberPages,((i-1)*1000),i,info.noOfPages,Members);
        } else  if (info.error) {
          document.getElementById('alList').disabled = false;
          document.getElementById('progress').innerHTML = "ERROR!";
          t.error=true;
        }
      },
    });
  },  

  fetchAllianceMemberPages : function (page,noOfPages,Members) {
      var t = Tabs.Alliance;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.pageNo = page;
      params.pf = 0;
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (transport) {
        var info = eval("(" + transport.responseText + ")");
        if (info.ok) {
            document.getElementById('searchProgress').value = page;
            for (var k in info["memberInfo"]){
              if ( info["memberInfo"][k]["might"] != undefined && !t.error){  
                  t.alliancemembers.push ({
                     Name: info["memberInfo"][k]["name"],
                     Might: parseInt(info["memberInfo"][k]["might"]),
                     Cities: parseInt(info["memberInfo"][k]["cities"]),
                     Position : parseInt(info["memberInfo"][k]["positionType"]),
                     dip : parseInt(info["memberInfo"][k]["daysInPosition"]),
                     LastLogin : info["memberInfo"][k]["lastLogin"],
                     uid : parseInt(info["memberInfo"][k]["userId"]),
                     fbuid : parseInt(info["memberInfo"][k]["fbuid"]),
                 avatarurl : info["memberInfo"][k]["avatarurl"],
                 glory : parseInt(info["memberInfo"][k]["glory"]),
                 dateJoined : info["memberInfo"][k]["dateJoined"],                 
                  });
                }
               document.getElementById('alOverviewTab').innerHTML ="";
               t.paintMembers();
          }
            if (params.pageNo == noOfPages) {
              document.getElementById('progress').innerHTML = '(' + (t.alliancemembers.length+1) +'/'+ Members +')';
              document.getElementById('alList').disabled = false;   
              document.getElementById('DIVsend').innerHTML = '<INPUT id=SendMSG type=submit class=pbButton value="Msg selected members...">';
              document.getElementById('SendMSG').addEventListener('click', function(){t.MsgPopUp();}, false);
            }
        } else  if (info.error) {
          document.getElementById('alList').disabled = false;
          document.getElementById('progress').innerHTML = "ERROR!";
          t.error=true;
        }
      },
    });
  },  
  hide : function (){},
  show : function (){},
};


/********************************* Messages Tab *************************************/
Tabs.Rpt = {
  tabOrder:    9,
  type: 'Tools',
  tabLabel:    'Reports',
  cont:        null,
  state:       null,
  minPages:    parseInt(Options.arPageFrom),
  maxPages:    parseInt(Options.arPageTo),
  data:        [],
  report:      [],
  totalPages:  parseInt(Options.arPageTo),
  what:        '',
  whatNot:     '',
  content:     '',

  init: function (div){
    var t = Tabs.Rpt;
    t.cont=div;
    unsafeWindow.getmsg = t.getMailBody;
    unsafeWindow.getReport = t.getReportBody;

    var tc = '<DIV class=pbStat>Alliance Report Scanner:</DIV>';
    tc += '<TABLE class=ptTab width=100%><TR><TD><INPUT id=togWatchdog type=checkbox '+(Options.watchdog?'CHECKED':'')+'> Post Alliance Reports to Chat</td>';
    tc += '<TD>Scan interval: <INPUT id=WatchdogInterval type=text size=3 value='+Options.WatchdogInterval+'> seconds</td>';
    tc += '<TD><TD><INPUT id=WatchDogFilter type=checkbox '+(Options.WatchDogFilter?'CHECKED':'')+'> Show friendly reports</td><TD><B>Check that only 1 member is running the scanner!!!</b></td></tr></table>'
    tc += '<BR><DIV class=pbStat>SEARCH INBOX, OUTBOX, PLAYER AND ALLIANCE REPORTS</DIV><DIV class=ptentry><TABLE><TR align=center valign=center>';
    tc += '<TD class=xtab align=right>Type:&nbsp;<SELECT id="idRptType">';
    tc += '<OPTION value="alliance" ' + (Options.rptType=='alliance'?'SELECTED':'') + '>Alliance Reports</OPTION>';
    tc += '<OPTION value="player" ' + (Options.rptType=='player'?'SELECTED':'') + '>Player Reports</OPTION>';
    tc += '<OPTION value="inbox" ' + (Options.rptType=='inbox'?'SELECTED':'') + '>Inbox</OPTION>';
    tc += '<OPTION value="outbox" ' + (Options.rptType=='outbox'?'SELECTED':'') + '>Outbox</OPTION></SELECT>';
    tc += '<BR />Pages:&nbsp;<INPUT id="idRptPageFrom" size=1 value="' + Options.arPageFrom + '">&#8211;<INPUT id="idRptPageTo" size=1 value="' + Options.arPageTo + '"></TD>';
    tc += '<TD class=xtab align=right>Attacker:&nbsp;<SELECT id="idRptAttacker">'; // Options.arPageFrom - Options.arPageTo
    tc += '<OPTION value="Them" ' + (Options.arAttacker=='Them'?'SELECTED':'') + '>Them</OPTION>';
    tc += '<OPTION value="Us" ' + (Options.arAttacker=='Us'?'SELECTED':'') + '>Us</OPTION>';
    tc += '<OPTION value="Both" ' + (Options.arAttacker=='Both'?'SELECTED':'') + '>Both</OPTION></SELECT>';
    tc += '<BR />Target:&nbsp;<SELECT id="idRptTarget">';
    tc += '<OPTION value="Them" ' + (Options.arTarget=='Them'?'SELECTED':'') + '>Them</OPTION>';
    tc += '<OPTION value="Us" ' + (Options.arTarget=='Us'?'SELECTED':'') + '>Us</OPTION>';
    tc += '<OPTION value="Both" ' + (Options.arTarget=='Both'?'SELECTED':'') + '>Both</OPTION></SELECT></TD>';
    tc += '<TD class=xtab align=right>Contains:&nbsp;<INPUT id=idRptWhat type=text size=11 maxlength=50 value=""><BR />';
    tc += 'But not:&nbsp;<INPUT id=idRptWhatNot type=text size=11 maxlength=50 value=""></TD>';
    tc += '<TD class=xtab align=left><INPUT id=idRptAttack type=checkbox '+(Options.arAttack?'CHECKED':'')+' />&nbsp;Attack<BR />';
    tc += '<INPUT id=idRptScout type=checkbox '+(Options.arScout?'CHECKED':'')+' />&nbsp;Scout</TD>';
    tc += '<TD class=xtab align=left><INPUT id=idRptReinforce type=checkbox '+(Options.arReinforce?'CHECKED':'')+' />&nbsp;Reinforce<BR />';
    tc += '<INPUT id=idRptTransport type=checkbox '+(Options.arTransport?'CHECKED':'')+' />&nbsp;Transport</TD>';
    tc += '<TD class=xtab align=left><INPUT id=idRptSearch type=submit class=pbButton value="Start Search" /></TD></TR></TABLE></DIV>';
    tc += '<DIV class=pbStat><TABLE width=100% cellspacing=0><TR><TD class=xtab align=left width=125><DIV id=idRptSearched></DIV></TD></TD>';
    tc += '<TD class=xtab><TD class=xtab align=center><SPAN style="white-space:normal" id=idRptStatus>&nbsp;</span></TD></TD>';
    tc += '<TD class=xtab><TD class=xtab align=right width=125><DIV id=idRptFound></DIV></TD></TR></TABLE></DIV>';
    tc += '<DIV id="idRptResultsDiv" style="height:556px; max-height:556px; overflow-x:auto; overflow-y:auto; white-space:nowrap;"></DIV>';
    t.cont.innerHTML = tc;
    document.getElementById('idRptType').addEventListener ('change', t.handleRptType, false);
    document.getElementById('idRptPageFrom').addEventListener ('change', t.handleRptPages, false);
    document.getElementById('idRptPageTo').addEventListener ('change', t.handleRptPages, false);
    document.getElementById('idRptAttacker').addEventListener ('change', t.handleRptAttacker, false);
    document.getElementById('idRptTarget').addEventListener ('change', t.handleRptTarget, false);
    document.getElementById('idRptWhat').addEventListener ('keyup', t.handleRptWhat, false);
    document.getElementById('idRptWhatNot').addEventListener ('keyup', t.handleRptWhatNot, false);
    document.getElementById('idRptSearch').addEventListener ('click', t.handleRptSearch, false);
    document.getElementById('togWatchdog').addEventListener ('click', t.SaveOptions, false);
    document.getElementById('WatchdogInterval').addEventListener ('change', t.SaveOptions, false);
    document.getElementById('WatchDogFilter').addEventListener ('click', t.SaveOptions, false);

    t.togOpt ('idRptAttack', 'arAttack');
    t.togOpt ('idRptScout', 'arScout');
    t.togOpt ('idRptReinforce', 'arReinforce');
    t.togOpt ('idRptTransport', 'arTransport');

    return this.cont;
  },
  
  SaveOptions:function(){
  		Options.watchdog = document.getElementById('togWatchdog').checked;
    	Options.WatchDogInterval = document.getElementById('WatchdogInterval').value;
    	Options.WatchDogFilter = document.getElementById('WatchDogFilter').checked;
    	saveOptions();
  },

  togOpt: function (checkboxId, optionName){
    var t = Tabs.Rpt;
    var checkbox = document.getElementById(checkboxId);
    checkbox.addEventListener ('change', eventHandler, false);
    function eventHandler (){
      Options[optionName] = this.checked;
      saveOptions();
      if (t.data.length > 0)
        if (Options.rptType == 'alliance' || Options.rptType == 'player')
          t.DisplayRpt();
        else
          t.DisplayMail();
    }
  },

  handleRptType: function(){
    var t = Tabs.Rpt;
    Options.rptType = document.getElementById("idRptType").value;
    saveOptions();
    document.getElementById("idRptSearched").innerHTML = '';
    document.getElementById("idRptStatus").innerHTML = '&nbsp;';
    document.getElementById("idRptFound").innerHTML = '';
    document.getElementById("idRptResultsDiv").innerHTML = '';
  },

  handleRptPages: function(){
    var t = Tabs.Rpt;
    t.minPages=parseInt(document.getElementById("idRptPageFrom").value);
    t.maxPages=parseInt(document.getElementById("idRptPageTo").value);
    if (t.maxPages < t.minPages) {
      t.maxPages = t.minPages;
      document.getElementById("idRptPageTo").value = t.maxPages;
    }
    Options.arPageFrom = t.minPages;
    Options.arPageTo = t.maxPages;
    saveOptions();
    t.totalPages=t.maxPages;
  },

  handleRptAttacker: function(){
    var t = Tabs.Rpt;
    Options.arAttacker = document.getElementById("idRptAttacker").value;
    saveOptions();
    if ((Options.rptType == 'alliance' || Options.rptType == 'player') && t.data.length > 0)
      t.DisplayRpt();
  },

  handleRptTarget: function(){
    var t = Tabs.Rpt;
    Options.arTarget = document.getElementById("idRptTarget").value;
    saveOptions();
    if ((Options.rptType == 'alliance' || Options.rptType == 'player') && t.data.length > 0)
      t.DisplayRpt();
  },

  handleRptWhat: function(){
    var t = Tabs.Rpt;
    t.what = document.getElementById("idRptWhat").value;
    if (t.data.length > 0)
      if (Options.rptType == 'alliance' || Options.rptType == 'player')
        t.DisplayRpt();
      else
        t.DisplayMail();
  },

  handleRptWhatNot: function(){
    var t = Tabs.Rpt;
    t.whatNot = document.getElementById("idRptWhatNot").value;
    if (t.data.length > 0)
      if (Options.rptType == 'alliance' || Options.rptType == 'player')
        t.DisplayRpt();
      else
        t.DisplayMail();
  },

  handleRptSearch: function(){
    var t = Tabs.Rpt;
    if (t.searchRunning){
      t.searchRunning = false;
      t.stopSearch ('SEARCH CANCELLED!');
      return;
    }
    t.handleRptPages();
    document.getElementById ('idRptSearch').value = 'Stop Search';
    document.getElementById('idRptStatus').innerHTML = 'Searching page ' + t.minPages + ' of ' + t.maxPages;
    t.searchRunning = true;
    t.data=[];
    t.report = [];
    if (Options.rptType == 'alliance' || Options.rptType == 'player')
      t.getRpt(t.minPages);
    else
      t.getMail(t.minPages);
  },

  stopSearch: function (msg){
    var t = Tabs.Rpt;
    if (t.searchRunning || msg == 'SEARCH CANCELLED!')
      document.getElementById ('idRptStatus').innerHTML = '<FONT color=#ffaaaa>' + msg + '</FONT>';
    document.getElementById ('idRptSearch').value = 'Start Search';
    t.searchRunning = false;
    if (Options.rptType == 'alliance' || Options.rptType == 'player')
      t.DisplayRpt();
    else
      t.DisplayMail();
  },

  getMail: function (pageNum){
    var t = Tabs.Rpt;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.pf=0;
    params.requestType="GET_MESSAGE_HEADERS_FOR_USER_INBOX";
    params.boxType = document.getElementById('idRptType').value;
    params.pageNo = pageNum;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        t.getMailCallback(rslt, pageNum);
      },
      onFailure: function () {
      },
    }, false);
  },

  getMailCallback: function(rslt, page) {
    var t = Tabs.Rpt;
    if (rslt) {
      if (!rslt.ok) {
        document.getElementById("idRptStatus").innerHTML = '<FONT color=#ffaaaa>' + rslt.errorMsg + '</FONT>';
        return;
      }
      t.totalPages=parseInt(rslt.noOfPages);
      if (t.totalPages < t.maxPages)
        t.maxPages = t.totalPages;
      if (rslt.message && page) {
        var ml = rslt.message;
        if (rslt.messageCount > 0) {
          var rptkeys = unsafeWindow.Object.keys(ml);
          for (var i = 0; i < rptkeys.length; i++) {
            var rpt = ml[rptkeys[i]];
            rpt.page = page;
            t.data.push(rpt);
          }
        }
      }
      if (parseInt(page)+1 <= t.maxPages && t.searchRunning) {
        document.getElementById("idRptStatus").innerHTML = 'Searching page ' + (parseInt(page)+1) + ' of ' + t.maxPages;
        t.getMail(parseInt(page)+1);
        if (t.data.length > 0)
          t.DisplayMail();
      } else if (page)
        t.stopSearch ('Done!');
    }
  },

  getRpt: function (pageNum){
    var t = Tabs.Rpt;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.pageNo = pageNum;
    if (Options.rptType == 'alliance')
      params.group = "a";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt){
        t.getRptCallback (rslt, pageNum);
      },
      onFailure: function (rslt){
        t.getRptCallback (rslt, pageNum);
      },
    }, false);
  },

  getRptCallback: function(rslt, page){
    var t = Tabs.Rpt;
    if (rslt) {
      if (!rslt.ok) {
        document.getElementById("idRptStatus").innerHTML = '<FONT color=#ffaaaa>' + rslt.errorMsg + '</FONT>';
        return;
      }
      t.totalPages=parseInt(rslt.totalPages);
      if (t.totalPages < t.maxPages)
        t.maxPages = t.totalPages;
      if (rslt.arReports && page) {
        var ar = rslt.arReports;
        if (ar.length == 0)
          t.stopSearch('Empty pages found from page ' + page + ' onwards - Kabam glitch');
        var rptkeys = unsafeWindow.Object.keys(ar);
        for (var i = 0; i < rptkeys.length; i++) {
          var rpt = ar[rptkeys[i]];
          var reportId = parseInt(rpt.reportId);
          t.report[reportId] = [];

          // Attacker
          t.report[reportId].side1Name = rslt.arPlayerNames['p'+rpt.side1PlayerId];
          t.report[reportId].side1AllianceId = parseInt(rpt.side1AllianceId);
          if (rpt.side1AllianceId > 0)
            t.report[reportId].side1AllianceName = rslt.arAllianceNames['a'+rpt.side1AllianceId];
          else
            t.report[reportId].side1AllianceName = 'unaligned';
          if (rpt.side1CityId > 0)
            t.report[reportId].side1CityName = rslt.arCityNames['c'+rpt.side1CityId];
          else
            t.report[reportId].side1CityName = 'none';
          t.report[reportId].side1XCoord = rpt.side1XCoord;
          t.report[reportId].side1YCoord = rpt.side1YCoord;
          // Target
          if (parseInt(rpt.side0PlayerId) == 0) { // Kabam
            t.report[reportId].side0Name = 'Enemy';
            t.report[reportId].side0AllianceName = '';
            t.report[reportId].side0CityName = '';
          } else { // Player
            t.report[reportId].side0Name = rslt.arPlayerNames['p'+rpt.side0PlayerId];
            if (rpt.side0AllianceId > 0)
              t.report[reportId].side0AllianceName = rslt.arAllianceNames['a'+rpt.side0AllianceId];
            else
              t.report[reportId].side0AllianceName = 'unaligned';
            if (rpt.side0CityId > 0)
              t.report[reportId].side0CityName = rslt.arCityNames['c'+rpt.side0CityId];
            else
              t.report[reportId].side0CityName = 'none';
          }
          t.report[reportId].side0AllianceId = parseInt(rpt.side0AllianceId);
          t.report[reportId].side0XCoord = rpt.side0XCoord;
          t.report[reportId].side0YCoord = rpt.side0YCoord;
          if (parseInt(rpt.side0TileType) == 10)
            t.report[reportId].side0TileTypeText='Grass';
          else if (parseInt(rpt.side0TileType) == 11)
            t.report[reportId].side0TileTypeText='Lake';
          else if (parseInt(rpt.side0TileType) == 20)
            t.report[reportId].side0TileTypeText='Woods';
          else if (parseInt(rpt.side0TileType) == 30)
            t.report[reportId].side0TileTypeText='Hills';
          else if (parseInt(rpt.side0TileType) == 40)
            t.report[reportId].side0TileTypeText='Mount';
          else if (parseInt(rpt.side0TileType) == 50)
            t.report[reportId].side0TileTypeText='Plain';
          else if (parseInt(rpt.side0CityId) ==0)
            t.report[reportId].side0TileTypeText='Barb';
          else
            t.report[reportId].side0TileTypeText='City';
          t.report[reportId].side0TileTypeLevel = t.report[reportId].side0TileTypeText + ' ' + rpt.side0TileLevel;
          t.report[reportId].side0TileType = rpt.side0TileType;
          t.report[reportId].side0TileLevel = rpt.side0TileLevel;
          // Miscellaneous
          t.report[reportId].page = page;
          t.report[reportId].reportUnixTime = rpt.reportUnixTime;
          if (rpt.side0AllianceId == parseInt(getMyAlliance()[0]))
            t.report[reportId].sideId = 0;
          else if (rpt.side1AllianceId == parseInt(getMyAlliance()[0])) {
            t.report[reportId].sideId = 1;
          } else { // if we're here then this is a player report from when they were in another alliance
            if (rpt.side0PlayerId == getMyUserId())
              t.report[reportId].sideId = 0;
            else if (rpt.side1PlayerId == getMyUserId())
              t.report[reportId].sideId = 1;
            else // shouldn't get here but we'll catch it if the report body is requested
              t.report[reportId].sideId = -1;
          }
          if (rpt.marchType == 0)
            t.report[reportId].marchName = 'Desertion';
          else if (rpt.marchType == 1)
            t.report[reportId].marchName = 'Transport';
          else if (rpt.marchType == 2)
            t.report[reportId].marchName = 'Reinforce';
          else if (rpt.marchType == 3) {
            if (t.report[reportId].sideId == 0)
              t.report[reportId].marchName = 'Anti-Scout';
            else
              t.report[reportId].marchName = 'Scout';
          } else if (rpt.marchType == 4) {
            if (t.report[reportId].sideId == 0)
              t.report[reportId].marchName = 'Defend';
            else
              t.report[reportId].marchName = 'Attack';
          } else
            t.report[reportId].marchName = '?';
          t.data.push ({
            reportId: reportId,
          });
        }
      }
      if (parseInt(page)+1 <= t.maxPages && t.searchRunning) {
        document.getElementById("idRptStatus").innerHTML = 'Searching page ' + (parseInt(page)+1) + ' of ' + t.maxPages;
        t.getRpt(parseInt(page)+1);
        if (t.data.length > 0)
          t.DisplayRpt();
      } else if (page)
        t.stopSearch ('Done!');
    }
  },

  DisplayMail: function (){
    var t = Tabs.Rpt;
    var results = document.getElementById("idRptResultsDiv");
    if(!t.data.length) {
      results.innerHTML = '<center>None found</center>';
      return;
    }
    reportsSearched = t.data.length;
    reportsFound = 0;
    t.content = '';
    for (var i=0; i<reportsSearched;i++) {
      var rpt = t.data[i];
      if ((t.what == '' || (rpt.subject.search(t.what, "i") != -1) || (rpt.displayName.search(t.what, "i") != -1))
        && (t.whatNot == '' || ((rpt.subject.search(t.whatNot, "i") == -1) && (rpt.displayName.search(t.whatNot, "i") == -1)))) {
        reportsFound++;
        if (reportsFound == 1)
          t.content += '<center><table><thead><th>P</th><th>Date</th><th>From</th><th>Subject</th></thead><tbody>';
        t.content += '<tr><td align=right>'+rpt.page+'</td><td>'+rpt.dateSent+'</td><td>'+rpt.displayName+'</td>';
        t.content += '<td><A><SPAN onclick="getmsg('+ rpt.messageId +')">' + rpt.subject + '</SPAN></a></td></tr>';
      }
    }
    if (reportsFound > 1)
      t.content += '</tbody></table></center>';
    if (reportsFound == 0 && reportsSearched > 0)
      t.content = '<center>None found</center>';
    results.innerHTML = t.content;
    document.getElementById("idRptSearched").innerHTML = '&nbsp;Searched: ' + reportsSearched;
    document.getElementById("idRptFound").innerHTML = 'Found: ' + reportsFound;
  },

  getMailBody: function(ID,dataI){
    var t = Tabs.Rpt;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.messageId=ID;
    params.requestType="GET_MESSAGE_FOR_ID";

    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok)
          t.displayMailBody(rslt.messageBody);
      },
      onFailure: function () {},
    }, false);
  },

  displayMailBody: function (messageBody) {
    var t = Tabs.Rpt;
    var popMsg = null;
    t.popMsg = new pbPopup('pbMailBody', 0, 0, 670, 600, true, function() {clearTimeout (1000);});
    t.popMsg.centerMe (mainPop.getMainDiv());
    var m = '<DIV style="max-height:565px; height:565px; overflow-y:scroll">';
    m+= messageBody + '</div>';
    t.popMsg.getMainDiv().innerHTML = m;
    t.popMsg.getTopDiv().innerHTML = '<DIV align=center><B>Message</B></DIV>';
    t.popMsg.show(true);
  },

  DisplayRpt: function (){
    var t = Tabs.Rpt;
    var results = document.getElementById("idRptResultsDiv");
    if(!t.data.length) {
      results.innerHTML = '<center>None found</center>';
      return;
    }
    var myAllianceId = parseInt(getMyAlliance()[0]);
    reportsSearched = t.data.length;
    reportsFound = 0;
    t.content = '';
    for (var i=0; i<reportsSearched;i++) {
      var reportId = t.data[i].reportId;
      var rpt = t.report[reportId];
      if ((rpt.side0Name=='undefined') && (rpt.marchName != 'Desertion'))
        continue;
      if ((((myAllianceId == parseInt(rpt.side1AllianceId) && Options.arAttacker != 'Them')
        || (myAllianceId != parseInt(rpt.side1AllianceId) && Options.arAttacker != 'Us')
        || Options.arAttacker == 'Both')
        && ((myAllianceId == parseInt(rpt.side0AllianceId) && Options.arTarget != 'Them')
        || (myAllianceId != parseInt(rpt.side0AllianceId) && Options.arTarget != 'Us')
        || Options.arTarget == 'Both')
        && ((Options.arAttack && (rpt.marchName == 'Attack' || rpt.marchName == 'Defend'))
        || (Options.arScout && (rpt.marchName == 'Scout' || rpt.marchName == 'Anti-Scout'))
        || (Options.arReinforce && rpt.marchName == 'Reinforce')
        || (Options.arTransport && rpt.marchName == 'Transport')))
        || (rpt.marchName == 'Desertion')) {
        if (((t.what == ''
          || (rpt.side1Name.search(t.what, "i") != -1)
          || (rpt.side1AllianceName.search(t.what, "i") != -1)
          || (rpt.side0Name.search(t.what, "i") != -1)
          || (rpt.side0AllianceName.search(t.what, "i") != -1)
          || (rpt.side0TileTypeText.search(t.what, "i") != -1))
          && (t.whatNot == ''
          || ((rpt.side1Name.search(t.whatNot, "i") == -1)
          && (rpt.side1AllianceName.search(t.whatNot, "i") == -1)
          && (rpt.side0Name.search(t.whatNot, "i") == -1)
          && (rpt.side0AllianceName.search(t.whatNot, "i") == -1)
          && (rpt.side0TileTypeText.search(t.whatNot, "i") == -1))))
          || (rpt.marchName == 'Desertion')) {
          reportsFound++;
          if (reportsFound == 1) {
            if (Options.enableReportNumber)
              t.content += '<center><table><thead><th>P</th><th>Date</th><th>Report</th><th>Attacker</th><th>From</th>';
            else
              t.content += '<center><table><thead><th>P</th><th>Date</th><th>Attacker</th><th>From</th>';
            if (Options.arAttacker != 'Us')
              t.content += '<th>Alliance</th>';
            t.content += '<th>Action</th><th>Target</th><th>Type</th><th>At</th>';
            if (Options.arTarget != 'Us')
              t.content += '<th>Alliance</th>';
            t.content += '<th>Dist</th><th>Nearest</th></thead><tbody>';
          }
          var closestDist=999999;
          var closestLoc=null;
          var closestNum=1;
          for (var c=0; c<Cities.numCities; c++){
            var city = Cities.cities[c];
            city.x +','+ city.y
            var dist=distance(city.x,city.y,rpt.side0XCoord,rpt.side0YCoord);
            if(dist<closestDist) {
              closestDist=dist;
              closestLoc=city.x +','+ city.y;
              closestNum=c+1;
            }
          }
          if (rpt.marchName == 'Anti-Scout' || rpt.marchName == 'Defend')
           style=' style="background-color:#EF9999;"';
          else if (rpt.marchName == 'Reinforce')
           style=' style="background-color:#99EF99;"';
          else
           style="";
          t.content += '<tr><td align=right '+style+'>'+rpt.page+'</td><td '+style+'>'+formatUnixTime(rpt.reportUnixTime,'24hour')+'</td>';
          if (Options.enableReportNumber)
            t.content += '<td '+style+'>' + reportId + '</td>';
          if (rpt.marchName == 'Desertion') {
            t.content += '<td '+style+'></td><td '+style+'></td>';
            if (Options.arAttacker != 'Us')
              t.content += '<td '+style+'></td>';
            t.content += '<td '+style+'>'+rpt.marchName+'</td><td '+style+'></td><td '+style+'></td><td '+style+'></td>';
            if (Options.arAttacker != 'Us')
              t.content += '<td '+style+'></td>';
            t.content += '<td '+style+'></td><td '+style+'></td>';
            } else {
            t.content += '<td '+style+'>'+rpt.side1Name+'</td><td align=center '+style+'><A onclick="pbGotoMap('+ rpt.side1XCoord +','+ rpt.side1YCoord +')">'+ rpt.side1XCoord +','+ rpt.side1YCoord +'</a></td>';
            if (Options.arAttacker != 'Us')
              t.content += '<td '+style+'>'+rpt.side1AllianceName+'</td>';
            t.content += '<td '+style+'><A><SPAN onclick="ptChatReportClicked('+ reportId+',0,999)">'+rpt.marchName+'</span></a></td>';
            t.content += '<td '+style+'>'+rpt.side0Name+'</td><td>'+rpt.side0TileTypeLevel+'</td>';
            t.content += '<td align=center '+style+'><A onclick="pbGotoMap('+ rpt.side0XCoord +','+ rpt.side0YCoord +')">'+ rpt.side0XCoord +','+ rpt.side0YCoord +'</a></td>';
            if (Options.arTarget != 'Us')
              t.content += '<td '+style+'>'+rpt.side0AllianceName+'</td>';
            t.content += '<td align=right '+style+'>'+Math.floor(closestDist)+'</td><td align=center '+style+'><A onclick=\"ptGotoCity(' + closestNum + ')\">' + closestLoc + '</a></td></tr>';
          }
        }
      }
    }
    if (reportsFound > 1)
      t.content += '</tbody></table></center>';
    if (reportsFound == 0 && reportsSearched > 0)
      t.content = '<center>None found</center>';
    results.innerHTML = t.content;
    document.getElementById("idRptSearched").innerHTML = '&nbsp;Searched: ' + reportsSearched;
    document.getElementById("idRptFound").innerHTML = 'Found: ' + reportsFound;
  },

  getReportBody: function(reportId){
    var t = Tabs.Rpt;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    //params.pf=0;
    params.rid=reportId;
    params.side=t.report[reportId].sideId;
    if (params.side > -1) {
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchReport.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          t.displayReportBody(rslt,reportId);
        },
        onFailure: function (rslt) {},
      }, false);
    } else {
      unsafeWindow.alert ('Could not determine which side of the report to view - please send details to the developer');
    }
  },

  displayReportBody: function (rslt, reportId) {
    var t = Tabs.Rpt;
    var popReport = null;
    var rpt = t.report[reportId];
    var m = '';
    var unitImg = [];
    for (var i=1;i<13;i++)
      unitImg[i] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.png></TD><TD>' + unsafeWindow.unitcost['unt'+i][0];
    unitImg[53] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_53_30.png></TD><TD>Crossbows';
    unitImg[55] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_55_30.png></TD><TD>Trebuchet';
    unitImg[60] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_60_30.png></TD><TD>Trap';
    unitImg[61] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_61_30.png></TD><TD>Caltrops';
    unitImg[62] = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_62_30.png></TD><TD>Spiked Barrier';
    goldImg = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png></TD><TD>Gold';
    foodImg = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png></TD><TD>Food';
    woodImg = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png></TD><TD>Wood';
    stoneImg = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png></TD><TD>Stone';
    oreImg = '<img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png></TD><TD>Ore';

    function buildHeader () {
      var h='<TABLE class=ptTab width=100%>';
      h+='<TR valign=top><TD align=left width=10%><B>';
      if (rpt.marchName == 'Anti-Scout' || rpt.marchName == 'Scout')
        h+=rpt.marchName+'ing at';
      else if (rpt.marchName == 'Attack' || rpt.marchName == 'Defend')
        h+='Battle at ';
      else if (rpt.marchName == 'Reinforce' || rpt.marchName == 'Transport')
        h+=rpt.marchName+' from<BR />'+rpt.marchName+' to</B>';

      if (rpt.side0TileTypeText == 'Barb')
        h+=' Barbarian Camp Level ' + rpt.side0TileLevel;
      else if (rpt.side0TileTypeText != 'City')
        h+=' '+rpt.side0TileTypeText+' Level '+ rpt.side0TileLevel+' ';
      h+='</B></TD>';

      if (rpt.marchName == 'Reinforce' || rpt.marchName == 'Transport') {
        h+='<TD align=left width=1%>';
        if (Seed.player.name != rpt.side1Name)
          h+=rpt.side1Name;
        if (Seed.player.name != rpt.side0Name)
          h+='<BR />'+rpt.side0Name;
        h+='</TD>';
      }
      h+='<TD align=left width=5%>';

      if (rpt.marchName == 'Reinforce' || rpt.marchName == 'Transport')
        h+='(<A onclick="pbGotoMap('+ rpt.side1XCoord +','+ rpt.side1YCoord +')">'+ rpt.side1XCoord +','+ rpt.side1YCoord +'</a>)<BR />';
      h+='(<A onclick="pbGotoMap('+ rpt.side0XCoord +','+ rpt.side0YCoord +')">'+ rpt.side0XCoord +','+ rpt.side0YCoord +'</a>)</TD>';

      if (rpt.side0TileTypeText != 'City' && rpt.side0TileTypeText != 'Barb' && rpt.marchName == 'Attack') {
        if (rslt['conquered']==1)
          h+='<TD><FONT color="#CC0000"><B>Conquered</B></font></td>';
        else if (rslt['conquered']==0)
          h+='<TD><FONT color="#66CC33"><B>Secured</B></font></td>';
      } else if (rpt.marchName == 'Reinforce' || rpt.marchName == 'Transport') {
        h+='<TD align=left width=5%>'+rpt.side1CityName+'<BR />';
        if (rpt.side0CityName != '')
          h+=rpt.side0CityName+'</TD>';
        else
          h+=rpt.side0TileTypeText+' Level '+ rpt.side0TileLevel+'</TD>';
      }

      h+='<TD align=right>' + formatUnixTime(rpt.reportUnixTime,'24hour') + '<BR />Report No: ' + reportId + '</TD></TR></TABLE>';
      return h;
    }

    function handleunts () { // Troops sent to Reinforce or troops found on a Scout
      var hunts = '', th = '', tc = '', tf = '';
      if (rslt['unts']) {
        if (rpt.marchName == 'Reinforce')
          th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Troops Reinforced</TH></TR>';
        else if (rslt['unts'])
          th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Troops Found</TH></TR>';
        for (var i=1;i<13;i++)
          if (rslt['unts']['u'+i])
            tc+='<TR><TD>' + unitImg[i] + '</TD><TD align=right>'+addCommas(rslt['unts']['u'+i])+'</TD></TR>';
        tf='</TABLE>';
      }
      if (tc != '')
        hunts = th + tc + tf;
      return hunts;
    }

    function handlersc () { // Resources brought with reinforcements or found on a Scout
      var hrsc = '', th = '', tc = '', tf = '';
      if (rslt['rsc']) {
        if (rslt['rsc']['r1'] > 0 || rslt['rsc']['r2'] > 0 || rslt['rsc']['r3'] > 0 || rslt['rsc']['r4'] > 0) {
          if (rpt.marchName == 'Reinforce')
            th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Goodies Brought</TH></TR>';
          else {
            th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Goodies Found</TH></TR>';
            if (rslt['gld'] > 0)
              tc+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommasInt(rslt['gld'])+'</TD></TR>';
          }
          if (rslt['rsc']['r1'] > 0)
            tc+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r1'])+'</TD></TR>';
          if (rslt['rsc']['r2'] > 0)
            tc+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r2'])+'</TD></TR>';
          if (rslt['rsc']['r3'] > 0)
            tc+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r3'])+'</TD></TR>';
          if (rslt['rsc']['r4'] > 0)
            tc+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r4'])+'</TD></TR>';
          tf='</TABLE>';
        }
      }
      if (tc != '')
        hrsc = th + tc + tf;
      return hrsc;
    }

    function handlefrt () { // Fortifications found on a Scout
      var hfrt = '', th = '', tc = '', tf = '';
      if (rslt['frt']) {
        if (rslt['frt']) {
          th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Defenses Found</TH></TR>';
          if (rslt['frt']['f53'])
            tc+='<TR><TD>' + unitImg[53] + '</TD><TD align=right>'+addCommas(rslt['frt']['f53'])+'</TD></TR>';
          if (rslt['frt']['f55'])
            tc+='<TR><TD>' + unitImg[55] + '</TD><TD align=right>'+addCommas(rslt['frt']['f55'])+'</TD></TR>';
          if (rslt['frt']['f60'])
            tc+='<TR><TD>' + unitImg[60] + '</TD><TD align=right>'+addCommas(rslt['frt']['f60'])+'</TD></TR>';
          if (rslt['frt']['f61'])
            tc+='<TR><TD>' + unitImg[61] + '</TD><TD align=right>'+addCommas(rslt['frt']['f61'])+'</TD></TR>';
          if (rslt['frt']['f62'])
            tc+='<TR><TD>' + unitImg[62] + '</TD><TD align=right>'+addCommas(rslt['frt']['f62'])+'</TD></TR>';
          tf='</TABLE>';
        }
      }
      if (tc != '')
        hfrt = th + tc + tf;
      return hfrt;
    }

    function handleblds (bType) {
      if(rslt['blds']){
      var blds = rslt['blds']['b'+bType]; b = '<TR><TD>'; arField = [], firstbld = true;
      if (bType == 1)
        b+='Farm';
      else if (bType == 2)
        b+='Sawmill';
      else if (bType == 3)
        b+='Quarry';
      else if (bType == 4)
        b+='Mine';
      b+='</TD><TD>';
      for (var i=1; i<12; i++)
        arField[i]=0;
      for (var i=0; i < blds.length; i++)
        arField[blds[i]]++
      for (var i=11; i>0; i--) {
        if (arField[i] > 0) {
          if (firstbld)
            firstbld = false;
          else
            b+=', ';
          if (arField[i] > 1)
            b+=arField[i] + ' x ';
          b+=' ' + i;
        }
      }
      b+='</TD></TR>';
      return b;
      }
    }

    if (rpt.marchName == 'Reinforce') {
      t.popReport = new pbPopup('pbShowRein', 0, 0, 525, 340, true, function() {clearTimeout (1000);});
      m+= '<DIV style="height:285px">';
    } else if (rpt.marchName == 'Transport') {
      t.popReport = new pbPopup('pbShowTrans', 0, 0, 525, 240, true, function() {clearTimeout (1000);});
      m+= '<DIV style="height:185px">';
    } else if (rpt.marchName == 'Scout' && rslt['winner']==1 && rpt.sideId==1){
      t.popReport = new pbPopup('pbShowOther', 0, 0, 550, 740, true, function() {clearTimeout (1000);});
      m+= '<DIV style="max-height:705px; height:705px; overflow-y:scroll">';
    } else {
      t.popReport = new pbPopup('pbShowOther', 0, 0, 550, 680, true, function() {clearTimeout (1000);});
      m+= '<DIV style="max-height:645px; height:645px; overflow-y:scroll">';
    }
    t.popReport.centerMe (mainPop.getMainDiv());

    m+=buildHeader();

    if (rpt.marchName == 'Transport') { // Transport
      m+='<TABLE class=ptTab>'; // Only transports have these in rslt, so handle them here
      if (parseInt(rslt['gold']) > 0)
        m+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommas(rslt['gold'])+'</TD></TR>';
      if (parseInt(rslt['resource1']) > 0)
        m+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommas(rslt['resource1'])+'</TD></TR>';
      if (parseInt(rslt['resource2']) > 0)
        m+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommas(rslt['resource2'])+'</TD></TR>';
      if (parseInt(rslt['resource3']) > 0)
        m+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommas(rslt['resource3'])+'</TD></TR>';
      if (parseInt(rslt['resource4']) > 0)
        m+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommas(rslt['resource4'])+'</TD></TR>';
      m+='</TABLE>';
    }

    m+='<TABLE class=ptTab>';
    if ((rslt['winner']==1 && rpt.sideId==0) || (rslt['winner']==0 && rpt.sideId==1)) {
      if (rpt.marchName == 'Scout')
        m+='<TR><TD><FONT color="#CC0000"><B>Scouting Failed</B></font></TD></TR>';
      else
        m+='<TR><TD><FONT color="#CC0000"><B>You were defeated</B></font></TD></TR>';
    }
    if (rslt['winner']==0 && rpt.sideId==0)
      m+='<TR><TD><FONT color="#66CC33"><B>You defended successfully!</B></font></TD></TR>';
    if (rslt['winner']==1 && rpt.sideId==1) {
      if (rpt.marchName == 'Scout')
        m+='<TR><TD><FONT color="#66CC33"><B>Scouting Report</B></font></TD></TR>';
      else
        m+='<TR><TD><FONT color="#66CC33"><B>You were victorious!</B></font></TD></TR>';
    }

    if (rslt['wall']) {
      if (rslt['wall'] == 100)
        m+='<TR><TD>Attackers breached the walls.</TD></TR>';
      else
        m+='<TR><TD>Attackers did not breach the walls. The walls are '+rslt['wall']+'% damaged</TD></TR>';
    }
    m+= '</TABLE><BR />';

    if (rslt['loot']) {
      m+='<TABLE class=ptTab>';
      if (rslt['loot'][0] > 0)
        m+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommas(rslt['loot'][0])+'</TD></TR>';
      if (rslt['loot'][1] > 0)
        m+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommas(rslt['loot'][1])+'</TD></TR>';
      if (rslt['loot'][2] > 0)
        m+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommas(rslt['loot'][2])+'</TD></TR>';
      if (rslt['loot'][3] > 0)
        m+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommas(rslt['loot'][3])+'</TD></TR>';
      if (rslt['loot'][4] > 0)
        m+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommas(rslt['loot'][4])+'</TD></TR>';
      if (rslt['loot'][5]) {
        for (var crest=1101; crest < 1116; crest++) {
          if (rslt['loot'][5][crest] == 1)
            m+='<TR><TD><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/' + crest + '.png></TD><TD colspan=2>' + crestname[crest] + '</TD></TR>';
        }
      }
      m+='</TABLE><BR />';
    }

    if (rpt.marchName == 'Reinforce') {
      m+=handleunts();
      m+=handlersc();
    }

    if (rpt.marchName == 'Scout' && rslt['winner']==1) {
      m+='<TABLE class=ptTab width=100%><TR><TD width=50% align=left valign=top>';
      m+=handleunts();
      m+=handlefrt();
      m+=handlersc();
      m+='</TD><TD width=50% align=left valign=top>';
      m+='<TABLE class=ptTab width=100%>';
      if (rslt['lstlgn']) {
        if (!rslt['lstlgn'])
          m+='<TR><TD>Last Login: Not recorded</TD></TR>';
        else
          m+='<TR><TD>Last Login: ' + formatUnixTime(rslt['lstlgn']) + '</TD></TR>';
      }
      m+='<TR><TD>Marshall Combat: ';
      if (rslt['knt'])
        m+=rslt['knt']['cbt'];
      else
        m+='None';
      m+='</TD></TR>';
      if (rslt['pop'])
        m+='<TR><TD>Population: ' + addCommas(rslt['pop']) + '</TD></TR>';
      if (rslt['hap'])
        m+='<TR><TD>Happiness: ' + addCommas(rslt['hap']) + '</TD></TR></TABLE>';
      if (rslt['blds']['b1'] || rslt['blds']['b2'] || rslt['blds']['b3'] || rslt['blds']['b4']) {
        m+='<TABLE class=ptTab><TR><TH colspan=2 align=left>Fields</TH></TR>';
        for (var i=1; i<5; i++)
          if (rslt['blds']['b'+i])
            m+=handleblds(i);
        m+='</TABLE>';
      }
      if (rslt['tch']) {
        m+='<TABLE class=ptTab><TR><TH colspan=2 align=left>Research</TH></TR>';
        for (var tl in rslt.tch)
          tid = /[0-9]/.exec(tl);
          m+='</TD></TR><TR><TD>'+unsafeWindow.techcost['tch'+tid[0]][0]+'</TD><TD align=right>' + rslt.tch[tl] + '</TD></TR>';
        m+='</TABLE>';
      }
      m+='</TD></TR></TABLE>';
    }

    if (rslt['fght']){ // not Reinforce or Transport, so we have a table with 2 columns: 1 for Attackers, 1 for Defenders
      m+='<TABLE class=ptTab width=100%><TR><TD width=50% align=left valign=top>';
      m+='<TABLE class=ptTab width=100%>';
      m+='<TR><TD colspan=4><B>Attackers</B> ('+rpt.side1Name+')';
      if (rslt['winner']==1)
        m+='<FONT color="#CC0000"><B> Winner</B></FONT>';
      m+='</TD></TR>';
      if (rpt.marchName == 'Attack' || rpt.marchName == 'Defend')
        m+='<TR><TD colspan=4>Knight Combat Skill: ' + rslt['s1KCombatLv'] + '</TD></TR>';
      m+='<TR><TD colspan=4>Attack Boosted: ' + 100*rslt['s1atkBoost'] + '%</TD></TR>';
      m+='<TR><TD colspan=4>Defense Boosted: ' + 100*rslt['s1defBoost'] + '%</TD></TR>';
      m+='<TR><TD colspan=4>(<A onclick="pbGotoMap('+ rpt.side1XCoord +','+ rpt.side1YCoord +')">'+ rpt.side1XCoord +','+ rpt.side1YCoord +'</a>) ' + rpt.side1CityName + '</TD></TR>';
      if (rslt['fght']["s1"] != undefined) {
        m+='<TR><TH></TH><TH align=left>Troops</TH><TH align=right>Fought</TH><TH align=right>Survived</TH></TR>';
        for (var i=1;i<15;i++) {
          if (rslt['fght']["s1"]['u'+i] != undefined) {
            if (rslt['fght']["s1"]['u'+i][0] > rslt['fght']["s1"]['u'+i][1]) {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][0])+'</td>';
              m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s1"]['u'+i][1])+'</FONT></td></tr>';
            } else {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][0])+'</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][1])+'</td></tr>';
            }
          }
        }
      }
      m+='</TABLE></TD><TD width=50% align=right valign=top>';
      m+='<TABLE class=ptTab width=100%>';
      m+='<TR><TD colspan=4><B>Defenders</B> ('+rpt.side0Name+')';
      if (rslt['winner']==0)
        m+='<FONT color="#CC0000"><B> Winner</B></FONT>';
      m+='</TD></TR>';
      if (rpt.marchName == 'Attack' || rpt.marchName == 'Defend')
        m+='<TR><TD colspan=4>Knight Combat Skill: ' + rslt['s0KCombatLv'] + '</TD></TR>';
      if (rslt['s0atkBoost'] !== undefined)
        m+='<TR><TD colspan=4>Attack Boosted: ' + 100*rslt['s0atkBoost'] + '%</TD></TR>';
      else
        m+='<TR><TD colspan=4>&nbsp;</TD></TR>';
      if (rslt['s0defBoost'] !== undefined)
        m+='<TR><TD colspan=4>Defense Boosted: ' + rslt['s0defBoost'] + '%</TD></TR>';
      else
        m+='<TR><TD colspan=4>&nbsp;</TD></TR>';
      m+='<TR><TD colspan=4>Rounds: ' + rslt['rnds'] + '</TD></TR>';
      if (rslt['fght']["s0"] != undefined) {
        m+='<TR><TH></TH><TH align=left>Troops</TH><TH align=right>Fought</TH><TH align=right>Survived</TH></TR>';
        for (var i=1;i<15;i++) {
          if (rslt['fght']["s0"]['u'+i] != undefined) {
            if (rslt['fght']["s0"]['u'+i][0] > rslt['fght']["s0"]['u'+i][1]) {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][0])+'</td>';
              m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['u'+i][1])+'</FONT></td></tr>';
            } else {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][0])+'</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][1])+'</td></tr>';
            }
          }
        }
        for (var i=53;i<=55;i++) {
          if (rslt['fght']["s0"]['f'+i] != undefined) {
            if (rslt['fght']["s0"]['f'+i][0] > rslt['fght']["s0"]['f'+i][1]) {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
              m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</font></td></tr>';
            } else {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</td></tr>';
            }
          }
        }
        for (var i=60;i<=63;i++) {
          if (rslt['fght']["s0"]['f'+i] != undefined) {
            if (rslt['fght']["s0"]['f'+i][0] > rslt['fght']["s0"]['f'+i][1]) {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
              m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</font></td></tr>';
            } else {
              m+='<TR><TD>' + unitImg[i] + '</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
              m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</td></tr>';
            }
          }
        }
      } else
        m+='<TR><TD>No Troops Defended</TD></TR>';
      m+='</TABLE></TD></TR></TABLE>';
    }

    m+='</DIV>';
    t.popReport.getMainDiv().innerHTML = m;
    t.popReport.getTopDiv().innerHTML = '<DIV align=center><B>'+rpt.marchName+' Report</B></DIV>';
    t.popReport.show(true);
  },

  show: function (){
  },

  hide: function (){
  },
};



/*********************************** Info tab ***********************************/
Tabs.Info = {
	tabOrder : 10,
	tabLabel : 'Info',
	type: 'Tools',
	myDiv : null,
	types: ["Life","Attack","Defense","Speed","Range","Load"],
	sacrifice: {1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false,11:false,12:false,13:false,14:false,15:false},
	base: {0:0,1:0,2:0,3:0,4:0,5:0},

  	init : function (div){
	    var t = Tabs.Info;
	    t.cont=div;
	    var m = '<DIV style="max-height:700px;overflow-y:auto"><DIV class=pbStat>TROOP STATS</div>'; 
	    m+= '<SPAN>This tab shows stats boosted <b>with</b> Research,Boosts,Knight,Guarian and TR <b>exept</b>: Bonus to PvP on Defense/Offense.</span>';   
	    m+='<TABLE class=pbTab><TR style="vertical-align:top"><TD style="width:350px"><DIV id=InfoLeft></div><TD width=50px>&nbsp</td></td><TD style="width:350px;text-align:center"><DIV id=InfoRight></div></td><TD width=50px>&nbsp</td></td><TD style="width:350px;text-align:center"><DIV id=InfoOptions></div></td></tr></table>';
	    m+='<DIV class=pbStat>THRONE ROOM EFFECTS INFO  -- <INPUT id=I_equipped type=checkbox unchecked=true>&nbspShow All Stats</div><BR><DIV id=InfoTRfx></div>';
	    t.cont.innerHTML = m;
	    document.getElementById('I_equipped').addEventListener("change", function () {
	    	if (document.getElementById('I_equipped').checked) t.PaintAllTRfx();
	    	 else t.PaintEquippedTRfx();
	    }, false);
	    var now = unixTime();
	   	t.PaintBoosts();
	    t.InitInfo();
	    t.PaintEquippedTRfx();
  	},
  	InitInfo:function(){
  		var t = Tabs.Info;
  		t.PaintKnights();
  		document.getElementById('O_City').innerHTML = '<B>' + t.Info.city.name + '</b>';
  		t.PaintGuardian();
  	},
  	PaintBoosts:function(){
  		var t = Tabs.Info;
  		var now = unixTime();
  		var boost_atk = ((Seed.playerEffects.atkExpire>now)?0.20:0) + ((Seed.playerEffects.atk2Expire>now)?0.5:0);
  		var boost_def = ((Seed.playerEffects.defExpire>now)?0.20:0) + ((Seed.playerEffects.def2Expire >now)?0.5:0);
  		var boost_ld = ((Seed.playerEffects.loadExpire>now)?0.25:0);
  		var items_atk=[261,262,280];
	   	var items_def=[271,272,281];
	   	var items_ld=[276,277,278];
	   	var tech={8:"Attack",9:"Defense",12:"Speed",13:"Range",10:"Load",15:"Life"};
  		var tech2={5:"Attack",6:"Range"};
		boosts = '<TABLE class=pbTab width=80%>'
		boosts += '<TR><TD colspan=5 style="text-align:center"><DIV class=pbStat id=O_City></div></td></tr>';
		boosts += '<TR><TD colspan=5 style="text-align:center"><SPAN id="InfoCity"></span></td></tr>';	
		boosts += '<TR><TD colspan=5 style="text-align:center"><SELECT id=I_Knight type=list></select></td></tr>';
  		boosts +='<TR><TD><B>Item</b></td><TD><B>Lvl</b></td><TD colspan=2><B>Boost</b></td>'
  		boosts += '<TR><TD>';
  		var boost_atk_time = "";
  		var boost_def_time = "";
  		var boost_ld_time = "";
  		if (Seed.playerEffects.atkExpire>now) boost_atk_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.atkExpire);
  		if (Seed.playerEffects.atk2Expire>now) boost_atk_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.atk2Expire);
  		if (Seed.playerEffects.defExpire>now) boost_def_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.defExpire);
  		if (Seed.playerEffects.def2Expire>now) boost_def_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.def2Expire);
  		if (Seed.playerEffects.loadExpire>now) boost_ld_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.loadExpire);
  		if (Seed.playerEffects.load2Expire>now) boost_ld_time = "&nbsp&nbsp Untill: "+FullDateTime(Seed.playerEffects.load2Expire);
  		for (var i=0;i<items_atk.length;i++) boosts += '<a class=hasTooltip><img width=25 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+items_atk[i]+'.jpg><SPAN>'+unsafeWindow.itemlist['i'+items_atk[i]].name+': '+unsafeWindow.itemlist['i'+items_atk[i]].description+'</span></a> ';
  		boosts += '</td><TD>--</td><TD style="text-align:right">'+(boost_atk*100)+'%</td><TD>&nbsp</td><TD style="text-align:left">Attack</td>&nbsp<TD>'+boost_atk_time+'</td></tr><TR><TD>';
		for (var i=0;i<items_def.length;i++) boosts += '<a class=hasTooltip><img width=25 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+items_def[i]+'.jpg><SPAN>'+unsafeWindow.itemlist['i'+items_def[i]].name+': '+unsafeWindow.itemlist['i'+items_def[i]].description+'</span></a> ';
		boosts += '</td><TD>--</td><TD style="text-align:right">'+(boost_def*100)+'%</td><TD>&nbsp</td><TD style="text-align:left">Defense</td>&nbsp<TD>'+boost_def_time+'</td></tr><TR><TD>';
		for (var i=0;i<items_ld.length;i++) boosts += '<a class=hasTooltip><img width=25 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/'+items_ld[i]+'.jpg><SPAN>'+unsafeWindow.itemlist['i'+items_ld[i]].name+': '+unsafeWindow.itemlist['i'+items_ld[i]].description+'</span></a> ';
		boosts += '</td><TD>--</td><TD style="text-align:right">'+(boost_ld*100)+'%</td><TD>&nbsp</td><TD style="text-align:left">Load</td>&nbsp<TD>'+boost_ld_time+'</td></tr>';
	   	for (var i in tech) {
	   		boosts += '<TR><TD ><a class=hasTooltip><img width=25 src=http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/tech/'+i+'_s33.png><SPAN>'+unsafeWindow.techcost['tch'+i][0]+'<br />'+unsafeWindow.techcost['tch'+i][10]+ '</span></a></td><TD>'+Seed.tech['tch'+i]+'</td>'
	   		if (i==10) boosts += '<TD style="text-align:right">'+(10 * parseInt(Seed.tech['tch'+i]))+'% </td><TD>&nbsp</td><TD style="text-align:left">'+tech[i]+'</td>';
	   		 else boosts += '<TD style="text-align:right">'+(5 * parseInt(Seed.tech['tch'+i]))+'% </td><TD>&nbsp</td><TD style="text-align:left">'+tech[i]+'</td>';
	   	}
	   	for (var i in tech2) {
	   		boosts += '<TR><TD ><a class=hasTooltip><img width=25 src=http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/tech2/'+i+'_s33.png><SPAN>'+unsafeWindow.techcost2['tch'+i][0]+'<br />'+unsafeWindow.techcost2['tch'+i][10]+ '</span></a></td><TD>'+Seed.tech2['tch'+i]+'</td>'
	   		boosts += '<TD style="text-align:right">'+(2 * parseInt(Seed.tech2['tch'+i]))+'% </td><TD>&nbsp</td><TD style="text-align:left">'+tech2[i]+'</td>';
	   	}
	   	boosts += '<TR><TD id=Guardian_Name></td><TD id=Guardian_Level></td><TD id=Guardian_Boost style="text-align:right"></td><TD>&nbsp</td><TD id=Guardian_Boost_Name style="text-align:left"></td></tr>';
	   	document.getElementById("InfoRight").innerHTML = boosts;
	   	document.getElementById('I_Knight').addEventListener("change", function () {t.PaintInfo();}, false);
	   	t.Info = new CdispCityPicker ('InfoCitySelect', document.getElementById('InfoCity'), false, t.InitInfo, 0); 	
  	},
  	PaintInfo : function(){
  		var t = Tabs.Info; 	
  		var now = unixTime();
  		var sacrificeLogo = '';
  		document.getElementById('InfoLeft').innerHTML = "";
 		var knight = (document.getElementById('I_Knight').value)/200;
 		var boost_atk = ((Seed.playerEffects.atkExpire>now)?0.20:0) + ((Seed.playerEffects.atk2Expire>now)?0.5:0);
  		var boost_def = ((Seed.playerEffects.defExpire>now)?0.20:0) + ((Seed.playerEffects.def2Expire >now)?0.5:0);
  		var boost_ld = ((Seed.playerEffects.loadExpire>now)?0.25:0);
  		var tech_hp = 			(5 * (parseInt(Seed.tech['tch15'])/100)); 
	    var tech_atk = 			(5 * (parseInt(Seed.tech['tch8'])/100)); 
	    var tech_def = 			(5 * (parseInt(Seed.tech['tch9'])/100)); 
	    var tech_spd_hb = 		(5 * (parseInt(Seed.tech['tch12'])/100)); 
	    var tech_rng = 			(5 * (parseInt(Seed.tech['tch13'])/100)) + (2 * (parseInt(Seed.tech2['tch6'])/100));
	    var tech_ld = 			(10 * (parseInt(Seed.tech['tch10'])/100)); 
	    var tech_bal_ram = 		(2 * (parseInt(Seed.tech2['tch5'])/100));
		//var tech_wall_field = 	(5 * (parseInt(Seed.tech2['tch4'])/100));
		var guardian_hp=1;
		var guardian_atk=1;
		if (t.guardian_type=="wood") guardian_hp=1+(t.guardian_boost/100);
		if (t.guardian_type=="ore") guardian_atk=1+(t.guardian_boost/100);
		var Fey_boost = ((Seed.cityData.city[t.Info.city.id].isPrestigeCity&&Seed.cityData.city[t.Info.city.id].prestigeInfo.blessings.indexOf(209)>0)?1.15:1);
  		var info ='<TABLE class=pbTab><TR><TD><img src='+sacrificeLogo+'></td><TD>&nbsp</td>';
  		for (var i=0;i<t.types.length;i++) info += '<TD style="text-align:right"><B>'+ t.types[i] + '</b></td>';
  		info+='</tr>';
  		var units = 15;
    	if (unsafeWindow.unitstats.unt16) units=16;
  		for (var i=1;i<=units;i++){
  			var tr_hp = tr_atk = tr_def = tr_spd = tr_rng = tr_ld = 0;
		    for (var y in unsafeWindow.cm.thronestats.effects){
		    	if (unsafeWindow.cm.thronestats.effects[y][7] == "0" && unsafeWindow.cm.thronestats.effects[y][3] == "Combat" && unsafeWindow.cm.thronestats.effects[y][5] == "") {
		    		var troop = false;
		    		if (unsafeWindow.cm.thronestats.effects[y][6]!="") for (var z=0;z<unsafeWindow.cm.thronestats.effects[y][6].length;z++) if (parseInt(unsafeWindow.cm.thronestats.effects[y][6][z])==i) troop=true;
		    		if (unsafeWindow.cm.thronestats.effects[y][6]=="") troop= true;
		    		if (troop) switch(unsafeWindow.cm.thronestats.effects[y][2][0]){
		    			case ("Life"): 		tr_hp += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    			case ("Attack"): 	tr_atk += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    			case ("Defense"): 	tr_def += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    			case ("Speed"): 	tr_spd += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    			case ("Range"): 	tr_rng += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    			case ("Load"): 		tr_ld += 	unsafeWindow.cm.ThroneController.effectBonus(parseInt(y))/100;break;
		    		}
		    	}
		    }
	   		for (var b=0;b<=5;b++) t.base[b] = unsafeWindow.unitstats['unt'+i][b] + ((t.sacrifice[i])?(unsafeWindow.unitstats['unt'+i][b]*0.03):0);
	   		info+='<TR><TD><INPUT type=checkbox id="Sacr_'+i+'" '+((t.sacrifice[i])?"checked":"unchecked")+'></td>';
	   		//https://kabam1-a.akamaihd.net/silooneofcamelot/fb/e2/src/img/units/unit_16_50.jpg
	   		//if (i==16) info+='<TD><a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_50.jpg?6545><SPAN>'+ t.PaintHover(i)+'</span></td>';
	   		info+='<TD><a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/silooneofcamelot/fb/e2/src/img/units/unit_'+i+'_50.jpg?6545><SPAN>'+ t.PaintHover(i)+'</span></td>';
	   		info+='<TD style="width:50px;text-align:right">'+	addCommas(Math.round((t.base[0] 	+(t.base[0]*(tech_hp+Math.min(tr_hp,2)))  )*guardian_hp ))+'</td>';
	   		info+='<TD style="width:50px;text-align:right">'+ 	addCommas(Math.round((t.base[1] 	+(t.base[1]*(tech_atk+((i>=10&&i<=11)?tech_bal_ram:0)+Math.min(tr_atk,8)+knight+2*boost_atk)))*guardian_atk*Fey_boost))   +'</td>';
	   		info+='<TD style="width:50px;text-align:right">'+	addCommas(Math.round(t.base[2] 		+(t.base[2]*(tech_def+Math.min(tr_def,40)+knight+2*boost_def) )))+'</td>';
	   		info+='<TD style="width:50px;text-align:right">'+	addCommas(Math.round(t.base[3] 		+(t.base[3]*(((i>=7&&i<=12)?tech_spd_hb:0)+Math.min(tr_spd,3)) )))+'</td>';
	   		info+='<TD style="width:50px;text-align:right">'+	addCommas(Math.round(t.base[4] 		+(t.base[4]*(((i==6||i==10||i==12)?tech_rng:0)+Math.min(tr_rng,1.5)))))+'</td>';
	   		info+='<TD style="width:50px;text-align:right">'+	addCommas(Math.round(t.base[5]		+(t.base[5]*(tech_ld+Math.min(tr_ld,5)+boost_ld))))+'</td>';
	   		info+= '</tr>';
	   	}
	   	info+='</table>';
	   	document.getElementById("InfoLeft").innerHTML = info;
	   	for (var i=1;i<=16;i++) document.getElementById('Sacr_'+i).addEventListener("click", function () {
			t.sacrifice[this.id.substr(5)]=this.checked;
			t.PaintInfo();
		}, false);
  	},
  	PaintHover: function(i){
  		var m= '<B>'+unsafeWindow.unitnamedesctranslated['unt'+i][0]+'</b><BR>';
  		m+="<TABLE class=pbTab width=100px>";
  		m+='<TR><TD style="width:50px"><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png></td><TD>'+addCommas(unsafeWindow.unitcost['unt'+i][1])+' ('+unsafeWindow.unitupkeeps[i]+')</td></tr>';
  		m+='<TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png></td><TD>'+addCommas(unsafeWindow.unitcost['unt'+i][2])+'</td></tr>';
  		m+='<TR><TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png></td><TD>'+addCommas(unsafeWindow.unitcost['unt'+i][3])+'</td></tr>';
  		m+='<TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png></td><TD>'+addCommas(unsafeWindow.unitcost['unt'+i][4])+'</td></tr>';
  		m+='<TR><TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/population_40.png></td><TD>'+addCommas(unsafeWindow.unitcost['unt'+i][6])+'</td></tr></table>';
  		return m;
  	},
  	PaintKnights: function(){
  		var t = Tabs.Info;
       	var knt = new Array();
       	var now = unixTime();
       	for (k in Seed.knights['city' + t.Info.city.id]){
       		if (Seed.leaders['city' + t.Info.city.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.Info.city.id][k]["knightId"] && Seed.leaders['city' + t.Info.city.id]["politicsKnightId"] != Seed.knights['city' + t.Info.city.id][k]["knightId"] && Seed.leaders['city' + t.Info.city.id]["combatKnightId"] != Seed.knights['city' + t.Info.city.id][k]["knightId"] && Seed.leaders['city' + t.Info.city.id]["intelligenceKnightId"] != Seed.knights['city' + t.Info.city.id][k]["knightId"]){
       			knt.push ({
       				Name:   Seed.knights['city' + t.Info.city.id][k]["knightName"],
       				Combat:	(parseInt(Seed.knights['city' + t.Info.city.id][k]["combat"])+((Seed.knights['city' + t.Info.city.id][k]["combatBoostExpireUnixtime"]>0)?(Math.floor(parseInt(Seed.knights['city' + t.Info.city.id][k]["combat"])*0.25)):0)),
       				ID:		Seed.knights['city' + t.Info.city.id][k]["knightId"],
       			});
       		}
       	}
       	knt = knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a > b ? -1 : 1);});
      	document.getElementById('I_Knight').options.length=0;	
       	for (k in knt){
    			if (knt[k]["Name"] !=undefined){
	    			var o = document.createElement("option");
	    			o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +')')
	    			o.value = knt[k]["Combat"];
	    			document.getElementById("I_Knight").options.add(o);
    			}
    	}
  	},
  	PaintAllTRfx:function(){
  		var t = Tabs.Info;
  		var info = '<TABLE class=pbTab width=90%><TD><B>Name</b></td><TD><B>FX</b></td><TD><B>Applies to</b></td><TD><B>Troops</b></td><TD><B>Side</b></td></tr>';
  		for (var i in unsafeWindow.cm.thronestats.effects){
  			var FX = unsafeWindow.cm.thronestats.effects[i];
  			info += '<TR><TD>' + FX[1] + '</td><TD>';
  			for (var y=0;y<FX[2].length;y++) info += FX[2][y] + ' ';
  			info += '</td><TD>'+ FX[5] +'</td><TD>';
  			for (var y=0;y<FX[6].length;y++) {
  				if (unsafeWindow.unitnamedesctranslated['unt'+FX[6][y]]) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+FX[6][y]+'_50.jpg?6545><SPAN>'+unsafeWindow.unitnamedesctranslated['unt'+FX[6][y]][0]+'</span></a> ';
  				else if (unsafeWindow.fortcost['frt'+FX[6][y]]) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+FX[6][y]+'_50.jpg?6545><SPAN>'+unsafeWindow.fortcost['frt'+FX[6][y]][0]+'</span></a> ';
  				else if (FX[6][y]==19) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/building_icons/build_walls_26.png><SPAN>Wall</span></a> ';
  				else info+= FX[6][y];
  			}		
  			info += '</td><TD>' + ((FX[7]=="0")?"You":"Them") + '</td></tr>';
  		}
  		document.getElementById('InfoTRfx').innerHTML = info + '</table><BR>';
  	},
  	PaintEquippedTRfx:function(){
  		var t = Tabs.Info;
  		var StatEffects = [];
  		var info = '<TABLE class=pbTab width=90%><TD colspan=2><B>Name</b></td><TD><B>FX</b></td><TD><B>Applies to</b></td><TD><B>Troops</b></td><TD><B>Side</b></td></tr>';
    	for (k in unsafeWindow.cm.thronestats.effects) StatEffects[k] = 0;
    	for (k in unsafeWindow.kocThroneItems){
    		 y = unsafeWindow.kocThroneItems[k];
	    	 for (i=1;i<=5;i++) {
				   id = y["effects"]["slot"+i]["id"];
				   tier = parseInt(y["effects"]["slot"+i]["tier"]);
				   level = y["level"];
				   p = unsafeWindow.cm.thronestats.tiers[id][tier];
				   Current = p.base + ((level * level + level) * p.growth * 0.5);
				   if (y.isEquipped && i<=y["quality"]) StatEffects[id] += Current
			}
		}
		for (k=1;k<StatEffects.length;k++){
			if (StatEffects[k]!=0){
				var FX = unsafeWindow.cm.thronestats.effects[k];
	  			info += '<TR><TD>'+StatEffects[k]+'%</td><TD>'+ FX[1] + '</td><TD>';
	  			for (var y=0;y<FX[2].length;y++) info += FX[2][y] + ' ';
	  			info += '</td><TD>'+ FX[5] +'</td><TD>';
	  			for (var y=0;y<FX[6].length;y++) {
	  				if (unsafeWindow.unitnamedesctranslated['unt'+FX[6][y]]) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+FX[6][y]+'_50.jpg?6545><SPAN>'+unsafeWindow.unitnamedesctranslated['unt'+FX[6][y]][0]+'</span></a> ';
	  				else if (unsafeWindow.fortcost['frt'+FX[6][y]]) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+FX[6][y]+'_50.jpg?6545><SPAN>'+unsafeWindow.fortcost['frt'+FX[6][y]][0]+'</span></a> ';
	  				else if (FX[6][y]==19) info += '<a class=hasTooltip><img  width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/building_icons/build_walls_26.png><SPAN>Wall</span></a> ';
	  				else info+= FX[6][y];
	  			}		
	  			info += '</td><TD>' + ((FX[7]=="0")?"You":"Them") + '</td></tr>';
	  		}
		} 
		document.getElementById('InfoTRfx').innerHTML = info + '</table><BR>';
  	},
  	PaintGuardian:function(){
  		var t = Tabs.Info;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		
		params.ctrl = 'Guardian';
		params.action = 'buildModal';
		params.cityId = t.Info.city.id;
		params.new_level = Seed.guardian[t.Info.city.idx]["level"];
		params.type = false;

  		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
		method: "post",
		parameters: params,
		loading: true,
		onSuccess: function (transport) {
			var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					var type = rslt.guardian.type;
					var boost = parseInt(rslt.guardian.cl3.charAt(1) + rslt.guardian.cl3.charAt(2));
					var index = rslt.guardian.cl3.indexOf("%");
					var boost_type = rslt.guardian.cl3.slice(index+2,rslt.guardian.cl3.length);
					t.guardian_boost = boost;
					t.guardian_type = type;
					document.getElementById('Guardian_Name').innerHTML =  unsafeWindow.g_js_strings.commonstr[type] + ' Guardian';
					document.getElementById('Guardian_Level').innerHTML = parseInt(rslt.guardian.cl0);
					document.getElementById('Guardian_Boost').innerHTML = boost + '%';
					document.getElementById('Guardian_Boost_Name').innerHTML = boost_type;
					t.PaintInfo();
				} 
		},
		onFailure: function () {
		   return;
		},
	});

  	},
	hide : function (){},
  	show : function (){},

}





/************************* Game/GUI Enhancements ***************************/

var ChatStuff = {
  chatDivContentFunc : null,
  getChatFunc : null,
  leaders : {},
  
  init : function (){
    var t = ChatStuff;
	if(getMyAlliance()[0] > 0) t.getAllianceLeaders();
	t.chatDivContentFunc = new CalterUwFuncTools ('Chat.chatDivContent', [['return f.join("")', 'var msg = f.join("");\n msg=chatDivContent_hook(msg,d);\n return msg;']]);
    unsafeWindow.chatDivContent_hook = t.chatDivContentHook;
    unsafeWindow.chatDivContent_hook2 = t.chatDivContentHook2;
    unsafeWindow.ptChatIconClicked = t.e_iconClicked;
    unsafeWindow.ptChatReportClicked = ReportFetch;
    unsafeWindow.ptTRcompClicked = t.TRcomp;
    t.setEnable (Options.chatEnhance);
    if (Options.chatglobal) document.getElementById('mod_comm_list1').className +=' ptChatGlobal ';
    //if (Options.chatalliance) document.getElementById('mod_comm_list2').className +=' ptChatAlliance ';
  },
  
  isAvailable : function (){
    var t = ChatStuff; 
    t.chatDivContentFunc.isAvailable ();
  },
  
  setEnable : function (tf){
    var t = ChatStuff; 
    t.chatDivContentFunc.setEnable (tf);
  },

  e_iconClicked : function (name){
    var e = document.getElementById('mod_comm_input');
    name = name.replace(/Ã‚Â°Ã‚Â°/g,"'");
    e.value = '@'+ name +' ';
  },
  
  chatDivContentHook2 : function (msg){
		var div = document.createElement('div');
		div.innerHTML = msg;
		div.innerText = div.innerHTML;
		msg = div.innerHTML.toString();
		return msg.htmlSpecialCharsDecode();
  },

 chatDivContentHook : function (msg,type){

 	   unsafeWindow.pbReinforce = CoordClick;
       var t = ChatStuff; 
       var element_class = '';
       var alliance = false;
       var whisper = false;
       var fbuid = 0;
       var m = /div class=\'info\'>.*<\/div>/im.exec(msg);
       if (m == null) return msg;
       if(type != null){
		   if(type.indexOf('says to the alliance') > 0)alliance = true;
		   if(type.indexOf('whispers to you') > 0) whisper = true;
	   }
       var whisp = m[0];
    
       	do {
			msg = msg.replace('cm.formatModel.jumpTo','pbReinforce');
		} while (msg.indexOf('cm.formatModel.jumpTo')>0)

    if (whisper) {
		if (Options.chatwhisper) element_class += ' ptChatWhisper ';	
    } else { //Global & Alliance
		if (Options.chatbold) element_class += ' ptChatBold ';
	}
	var scripters = ["7552815","10681588","1747877","2865067","10153485","15182839","1550996","1617431819","9688786","8184813","9863346","11107993","9751486","5614388","424090","14845619"];
	var suid = /viewProfile\(this,([0-9]+),false/i.exec(m[0]);
	if(!suid) {
		suid = unsafeWindow.tvuid;
		fbuid = unsafeWindow.user_id;
	} else suid = suid[1];	
	if (Options.chatLeaders) if (t.leaders[suid]) element_class += ' ptChat'+t.leaders[suid];  
	if (scripters.indexOf(suid) >= 0) element_class += ' ptChatScripter'; 
	if(alliance){
	if (m[0].indexOf('My embassy has') >= 0 && Options.chatAttack) element_class = ' ptChatAttack';
	if (m[0].indexOf('My wilderness at') >= 0 && Options.chatAttack) element_class = ' ptChatAttack';
	if (m[0].indexOf('..:.')>0) element_class = ' ptChatAttack';
	if (element_class == ' ptChatAttack') {
		if (m[0].indexOf('SCOUT')>0 || m[0].indexOf('Scouting')>0 || m[0].indexOf('Scouted')>0) var url = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/scouting.jpg';
		else var url = 'https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg';
	 	msg += '<div style="position:absolute;background-image:url('+url+'); background-repeat:no-repeat;border-radius: 3px 3px 3px 3px;height:18px;width:18px;border:2px inset rgb(96, 0, 0);box-shadow:0px 0px 2px rgb(255, 255, 255);left:4px;top:40px;"></div>';
	}
	if (m[0].indexOf('..:.') >= 0 && Options.chatAttack) {
			var f = msg.indexOf('<div class=\'tx\'>');
			if(f >= 0) {
				msg = msg.replace(/<div class=\'tx\'>/,'<div class=\'tx\'><center><table cellpadding=1 cellspacing=0 border="1" style="border: 1px solid; border-style: none none none none;"><tr><td style="background-color:'+Colors.ChatAtt+'">')
				msg = msg.replace(/\|\|/g,'</td></tr><tr><td style="background-color:'+Colors.ChatAtt+'">');
				var a = msg.indexOf('</div>',f);
				msg = msg.slice(0,a)+'</td></tr></table></center>'+msg.slice(a);
				
			}
			msg = msg.replace(/\|/g,'<br>');
			msg = msg.replace('..:.','');
			if (Options.enableTowerAlert) {
				AudioManager.setSource(SOUND_FILES.alert);
				AudioManager.play();
				setTimeout(function(){AudioManager.stop();}, 5000);
			}
		}
		if (m[0].indexOf('.::.') >= 0 && Options.chatAttack) {
			element_class = ' ptChatRecall';
			var f = msg.indexOf('<div class=\'tx\'>');
			if(f >= 0) {
				msg = msg.replace(/<div class=\'tx\'>/,'<div class=\'tx\'><center><table cellpadding=1 cellspacing=0 border="1" style="border: 1px solid; border-style: none none none none;"><tr><td>')
				msg = msg.replace(/\|\|/g,'</td></tr><tr><td>');
				var a = msg.indexOf('</div>',f);
				msg = msg.slice(0,a)+'</td></tr></table></center>'+msg.slice(a);
				
			}
			msg = msg.replace(/\|/g,'<br>');
			msg = msg.replace('.::.','');
		}
	 }

	 if(m[0].indexOf(':::.') >= 0) {
			var f = msg.indexOf('<div class=\'tx\'>');
			if(f >= 0) {
				msg = msg.replace(/<div class=\'tx\'>/,'<div class=\'tx\'><center><table cellpadding=1 cellspacing=0 border="1" style="border: 1px solid; border-style: none none none none;"><tr><td>')
				msg = msg.replace(/\|\|/g,'</td></tr><tr><td>');
				var a = msg.indexOf('</div>',f);
				msg = msg.slice(0,a)+'</td></tr></table></center>'+msg.slice(a);
			}
			msg = msg.replace(/\|/g,'<br>');
			msg = msg.replace(':::.','');
	}
	
     msg = msg.replace ("class=\'content\'", "class='content "+ element_class +"'");
	 msg = msg.replace (/(\bReport\sNo\:\s([0-9]+))/g, '<a onclick=\'ptChatReportClicked($2,0,999)\'>$1</a>');

	 if (m[0].indexOf('TRC:')){
	 	unsafeWindow.suid = suid;
	 	msg = msg.replace (/(\bTRC:\s([0-9]+))/g, '<a onclick=\'ptTRcompClicked($2,suid)\'>"Compare Throne Room"</a>');
	 }

     var m = /(Lord|Lady) (.*?)</im.exec(msg);
     if (m != null) m[2] = m[2].replace(/\'/g,"Ã‚Â°Ã‚Â°");
     msg = msg.replace (/<img (.*?>)/img, '<A onclick=\"ptChatIconClicked(\''+ m[2] +'\')\"><img class=\"ptChatIcon\" $1</a>');

     if (whisper && Options.enableWhisperAlert) {
		AudioManager.setSource(SOUND_FILES.whisper);
		AudioManager.play();
		setTimeout(function(){AudioManager.stop();}, 2500);
     } 
     if(alliance){
		 if (whisp.indexOf('My embassy has') >= 0 && Options.enableTowerAlert) {
			AudioManager.setSource(SOUND_FILES.alert);
			AudioManager.play();
			setTimeout(function(){AudioManager.stop();}, 5000);
		 } 
		 if (whisp.indexOf('My wilderness at') >= 0 && Options.enableTowerAlert) {
			AudioManager.setSource(SOUND_FILES.alert);
			AudioManager.play();
			setTimeout(function(){AudioManager.stop();}, 5000);
		 }
	 }

     return t.getFid(msg,suid);
   },

  getFid : function (msg,suid) {
  		var t = ChatStuff;
  		if (ChatIcons.fidCache.indexOf(suid) == -1) {
  			var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
			params.pid = suid;

	   		new AsyncAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				loading: true,
				onSuccess: function (transport) {
					var rslt = eval("(" + transport.responseText + ")");
						if(rslt.ok){
							ChatIcons.fidCache.push(suid);
							ChatIcons.fidCache.push(rslt.playerInfo.fbuid);
							ChatIcons.ReqSend++;
							saveChatIcons();
							var url = "https://graph.facebook.com/"+ ChatIcons.fidCache[ChatIcons.fidCache.indexOf(suid) +1] +"/picture";
	 						msg = msg.replace (/\bhttps\:\/\/[-a-z].*\'\/\>/i, url +'\'\/\>');
					   } 
				},
				onFailure: function () {
				   return;
				},
			}); 
  		}
	 	else {
	 		var url = "https://graph.facebook.com/"+ ChatIcons.fidCache[ChatIcons.fidCache.indexOf(suid) +1] +"/picture";
	 		msg = msg.replace (/\bhttps\:\/\/[-a-z].*\'\/\>/i, url +'\'\/\>');
	 		
	 	}

	 	return msg;
   },

   DataGoodSide: false,
   DataBadSide:false,
   BadSideStatEffects: [],
   GoodSideStatEffects: [],

   TRcomp : function (pid,uid){
	   	var t = ChatStuff;
	   	t.DataGoodSide = false;
	    t.DataBadSide =false;
		t.TRStatsGoodSide(uid,pid);
	},

	TRStatsGoodSide : function (Goodside,BadSide){
  	var t = ChatStuff;
  	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
	params.action = 'getEquipped';
	params.playerId = Goodside;
	
  	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
		method: "post",
		parameters: params,
		loading: true,
		onSuccess: function (transport) {
			var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					for (k in unsafeWindow.cm.thronestats.effects) t.GoodSideStatEffects[k] = 0;
					for (kk=0;kk<7;kk++){
    		 			y = rslt.items[kk];
	    	 			if (y != undefined) {
		    	 			for (i=1;i<=5;i++) {
					   			   id = y["effects"]["slot"+i]["id"];
								   tier = parseInt(y["effects"]["slot"+i]["tier"]);
								   level = y["level"];
								   p = unsafeWindow.cm.thronestats.tiers[id][tier];
								   Current = p.base + ((level * level + level) * p.growth * 0.5);
								   if (i<=parseInt(y["quality"])) t.GoodSideStatEffects[id] += Current;
							}
						}
					}
					t.DataGoodSide= true;
					setTimeout(t.TRStatsBadSide,500,BadSide);
			   } else t.GoodSideStatEffects();
		},
		onFailure: function () {
		   return;
		},
	}); 	  	  	
  },

  TRStatsBadSide : function (BadSide){
  	var t = ChatStuff;
  	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.ctrl = 'throneRoom\\ThroneRoomServiceAjax';
	params.action = 'getEquipped';
	params.playerId = BadSide;
	
  	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
		method: "post",
		parameters: params,
		loading: true,
		onSuccess: function (transport) {
			var rslt = eval("(" + transport.responseText + ")");
				if(rslt.ok){
					for (k in unsafeWindow.cm.thronestats.effects) t.BadSideStatEffects[k] = 0;
					for (kk=0;kk<7;kk++){
    		 			y = rslt.items[kk];
	    	 			if (y != undefined) {
		    	 			for (i=1;i<=5;i++) {
					   			   id = y["effects"]["slot"+i]["id"];
								   tier = parseInt(y["effects"]["slot"+i]["tier"]);
								   level = y["level"];
								   p = unsafeWindow.cm.thronestats.tiers[id][tier];
								   Current = p.base + ((level * level + level) * p.growth * 0.5);
								   if (i<=parseInt(y["quality"])) t.BadSideStatEffects[id] += Current;
							}
						}
					}
					t.DataBadSide= true;
					if (t.DataGoodSide && t.DataBadSide) t.PaintTRCompare();
			   } else t.TRStatsBadSide();
		},
		onFailure: function () {
		   return;
		},
	}); 	  	  	
  },

  PaintTRCompare : function (){
  	var t = ChatStuff;
  	m = 'This info needs testing, ePlZnZX give me feedback ;)<BR><BR><TABLE><TD class=xtab></td><TD class=xtab><B>BadSide</b><TD></td><TD class=xtab><B>Goodside</b></td></tr><TR><TD>&nbsp</td></tr>';
	for (k=1;k<t.GoodSideStatEffects.length;k++) {
		var BadSideContent = "";
		var GoodSideContent = "";
		if (t.BadSideStatEffects[k] != 0) BadSideContent = t.BadSideStatEffects[k] + '% ' + unsafeWindow.cm.thronestats["effects"][k]["1"];
		if (t.GoodSideStatEffects[k] != 0) GoodSideContent = t.GoodSideStatEffects[k] + '% ' + unsafeWindow.cm.thronestats["effects"][k]["1"];

		if (t.BadSideStatEffects[k] != 0 || t.GoodSideStatEffects[k] != 0) m+='<TR><TD  width="25px" class=xtab></td><TD class=xtab>' + BadSideContent + '</td><TD  width="50px" class=xtab></td><TD class=xtab>' + GoodSideContent + '</td></tr>';
	}
	m +='</table>';
	var popMsg = null;
	t.popMsg = new pbPopup('pbMailBody', 0, 0, 550, 750, true, function() {clearTimeout (1000);});
	t.popMsg.centerMe (mainPop.getMainDiv());
	t.popMsg.getMainDiv().innerHTML = m;
	t.popMsg.getTopDiv().innerHTML = '<DIV align=center><B>Throne Room Compare</B></DIV>';
	t.popMsg.show(true); 	
  },
   
   getAllianceLeaders : function (){
   var t = ChatStuff;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetLeaders.php" + unsafeWindow.g_ajaxsuffix, {
		 method: "post",
		 parameters: params,
		 loading: true,
		 onSuccess: function (rslt) {
			 if (rslt.officers) {
				for (uid in rslt.officers) {
					var user = rslt.officers[uid];
					t.leaders[user.userId] = user.type.substr(0,4);
				}
			 } 
		},
		onFailure: function () {}
  		});
	},
   
 }

 var AudioManager = {
  player: null,
  volume: 100,
  type: 'html5',
  alertdiv: null,
  init: function (){
	var t = AudioManager;
	if ( !! document.createElement("audio").canPlayType) {
		t.player = new Audio();
		t.type = 'html5';
		t.player.addEventListener("ended", function () {
			t.player.currentTime = 0
		}, false);
		t.setVolume(t.volume);
	} else {
		t.creatediv();
		t.type = 'swf';
	}
  },
  setVolume: function(vol){
	var t = AudioManager;
	t.volume = vol;
	t.player.volume = t.volume * 0.01;
  },
  play: function(){
	var t = AudioManager;
	if(t.type == 'html5'){
		if (!t.player.paused) {
			t.stop();
		}
		t.player.play();
	} else {
		t.alertdiv.innerHTML = t.source;
	}
  },
  stop: function(){
	var t = AudioManager;
	if(t.type == 'html5'){
		t.player.pause();
		if (t.player.readyState === 4) {
			t.player.currentTime = 0
		}
	} else {
		t.alertdiv.innerHTML = '<b style=\'color: rgb(165, 102, 49); font-size: 9px;\'>Audio Alert Played</b>';
	}
  },
  pause: function(){
	var t = AudioManager;
	t.player.pause();
  },
  setSource: function(src){
	var t = AudioManager;
	if(t.type == 'html5'){
		t.player.src = src.OGG;
		t.source = src.OGG;
	} else
		t.source = src.DEFAULT;
  },
  toggleMute: function () {
	var t = AudioManager;
    t.player.muted = !t.player.muted;
  },
  creatediv : function(){
    var t = AudioManager;
    var div = document.getElementsByTagName('div');
	for (var i = 0; i < div.length - 1; i++)
		if (div[i].className == 'mod_comm_forum')
			e = div[i];
	t.alertdiv = document.createElement("span");
	e.appendChild(t.alertdiv);
  },
}

function GetNames (rptid, side, rslt){
	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.uid=rslt.index.side0PlayerId;
	var side0AllianceId = null;
	var side0Name = null;
	var side0AllianceName = null;
	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
		method: "post",
		parameters: params,
		onSuccess: function (transport) {
			var rslt0 = eval("(" + transport.responseText + ")");
			if (rslt0['userInfo']) {
				side0Name = rslt0['userInfo']['0']['name'];
				side0AllianceName = rslt0['userInfo']['0']['allianceName'];
				side0AllianceId = rslt0['userInfo']['0']['allianceId'];
			}
			var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
				params.uid=rslt.index.side1PlayerId;
				new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
					method: "post",
					parameters: params,
					onSuccess: function (transport) {
						var rslt1 = eval("(" + transport.responseText + ")");
						side1Name = rslt1['userInfo']['0']['name'];
						side1AllianceName = rslt1['userInfo']['0']['allianceName'];
						if (parseInt(side0AllianceId) == parseInt(Seed.allianceDiplomacies.allianceId)) side = 0;
						 else side = 1;
						rslt = rslt.index;
						ReportFetch(rslt.marchReportId,side,rslt.side0TileType,rslt.side0TileLevel,rslt.side0PlayerId,side0Name,0,side1Name,0,rslt.marchType,rslt.side0XCoord,rslt.side0YCoord,rslt.reportUnixTime,false,rslt.side1XCoord,rslt.side1YCoord,side0AllianceName,side1AllianceName,true);					
					},
					onFailure: function () {
						alert('kabam is having issues');
					},
				}, false);
		},					
		onFailure: function () {
			alert('kabam is having issues');
		},
	}, false);
}

function ReportFetch (rptid, side, tiletype, tilelv, defid, defnm, defgen, atknm, atkgen, marchtype, xcoord, ycoord, timestamp, unread, atkxcoord, atkycoord,side0AllianceName,side1AllianceName,link){
	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.rid=rptid;
	if (tiletype != 999) params.side = side;
	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchReport.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				onSuccess: function (transport) {
					var rslt = eval("(" + transport.responseText + ")");
					if (rslt.ok == false) {alert(rslt.msg);return;}
					if (!rslt.error){		
						if (tiletype !=999 )PaintPvpReport(rslt, rptid, side, tiletype, tilelv, defid, defnm, defgen, atknm, atkgen, marchtype, xcoord, ycoord, timestamp, unread, atkxcoord, atkycoord,side0AllianceName,side1AllianceName,link);
						else GetNames(params.rid, side, rslt);
					} else alert('kabam is having issues with reports...');	

				},
				onFailure: function () {
					alert('kabam is having issues with reports...');
				},
	}, false);
}

function PaintPvpReport (rslt, rptid, side, tiletype, tilelv, defid, defnm, defgen, atknm, atkgen, marchtype, xcoord, ycoord, timestamp, unread, atkxcoord, atkycoord,side0AllianceName,side1AllianceName,link){
	var popReport = null;
	var action='';
	popReport = new pbPopup('pbShowPvp', 0, 0, 740, 600, true, function() {if (unread){unsafeWindow.seed.newReportCount = parseInt(Seed.newReportCount) - 1;unsafeWindow.messages_notify_bug()}unsafeWindow.pageNavigatorModel.gotoPage(1);unsafeWindow.Messages.listReports();clearTimeout (1000);});
	popReport.centerMe (mainPop.getMainDiv());
	var color ='none';
	if (defid == unsafeWindow.tvuid && rslt.winner == 1) color = "#FF2934";
	if (defid != unsafeWindow.tvuid && rslt.winner == 0) color = "#FF2934";
	if (defid == unsafeWindow.tvuid && rslt.winner == 0) color = "#3EC249";
	if (defid != unsafeWindow.tvuid && rslt.winner == 1) color = "#3EC249";
	if (rslt.winner == 2) color = "#EDD118";
	if (side0AllianceName == Seed.allianceDiplomacies.allianceName && rslt.winner == 1) color = "#FF2934";
	if (side0AllianceName != Seed.allianceDiplomacies.allianceName && rslt.winner == 0) color = "#FF2934";
	if (side0AllianceName == Seed.allianceDiplomacies.allianceName && rslt.winner == 0) color = "#3EC249";
	if (side0AllianceName != Seed.allianceDiplomacies.allianceName && rslt.winner == 1) color = "#3EC249";
	if (rslt.winner == 2) color = "#EDD118";	

	switch (parseInt(marchtype)) {
		case (3):
				var login = '';
 				if (defid != unsafeWindow.tvuid) login = 'Last Login: ' + FullDateTime(rslt.lstlgn);
				var m = '<DIV style="height:575px;max-height:575px;overflow-y:auto;"><DIV style="background-color:'+color+';"><TABLE width="100%" class=pbTab><TR><TD>Time: ' + FullDateTime(timestamp) + '</td><TD align=center>Report No: ' + rptid + '</td><TD align=right><INPUT id=PostToChat type=submit class=pbButton value="Post to chat"></td></tr>';
				m+= '<TR><TD></td>'
				if (tiletype == 51 && defnm != null && side0AllianceName != Seed.allianceDiplomacies.allianceName) m+= '<TD align=center><FONT size=3><B>' + login + '</b></font></td>';
				else m+='<TD></td>';
				if (!link) m+='<TD align=right><INPUT id=Delete type=submit class=pbButton value="Delete"></td>';
				m+='</tr></table></div>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=InfoSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=InfoSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TroopsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TroopsSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=StatsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=StatsSide0></div></td></tr></table>';	
				if (defid != unsafeWindow.tvuid && side0AllianceName != Seed.allianceDiplomacies.allianceName) m+= '<BR><DIV class=pbStat>RESOURCES FOUND</div><DIV id=ScoutResources></div>';
				if (defid != unsafeWindow.tvuid && side0AllianceName != Seed.allianceDiplomacies.allianceName) m+= '<BR><DIV class=pbStat>TROOPS & FORTIFICATIONS</div><DIV id=ScoutTroops></div>';
				if (defid != unsafeWindow.tvuid && side0AllianceName != Seed.allianceDiplomacies.allianceName) m+= '<BR><DIV class=pbStat>BUILDINGS & RESEARCH</div><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=Buildings></div></td><TD valign=top width=370px max-width=370px><DIV id=Research></div></td></tr></table>';
				m+= '<BR><DIV class=pbStat>BOOSTS</div><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=ItemsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=ItemsSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TechSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TechSide0></div></td></tr></table>';
				m+= '<BR><DIV class=pbStat>THRONE ITEMS</div><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TRSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TRSide0></div></td></tr></table>';
				m+='</table></div>';
				if (defid != unsafeWindow.tvuid && side0AllianceName != Seed.allianceDiplomacies.allianceName) action = "SCOUT";
				else action = "ANTI-SCOUT";
				break;
		case (4):
				var m = '<DIV style="height:575px;max-height:575px;overflow-y:auto;"><DIV style="background-color:'+color+';"><TABLE width="100%" class=pbTab><TR><TD>Time: ' + FullDateTime(timestamp) + '</td><TD align=center>Report No: ' + rptid + '</td><TD align=right><INPUT id=PostToChat type=submit class=pbButton value="Post to chat"></td></tr>';
				m+= '<TR><TD></td>';
				if (tiletype == 51 && defnm != null) m+='<TD align=center><FONT size=3><B>Glory: ' + addCommas(rslt.glory) + '</b></font></td>';
				else m+='<TD></td>';
				if (!link) m+='<TD align=right><INPUT id=Delete type=submit class=pbButton value="Delete"></td>';
				m+='</tr></table></div>';
				m+= '<BR><DIV id=rptResources></div>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=InfoSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=InfoSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TroopsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TroopsSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=StatsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=StatsSide0></div></td></tr></table>';
				m+= '<BR><DIV class=pbStat>BOOSTS</div><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=ItemsSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=ItemsSide0></div></td></tr></table>';
				m+= '<BR><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TechSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TechSide0></div></td></tr></table>';
				m+= '<BR><DIV class=pbStat>THRONE ITEMS</div><TABLE class=pbTab width=100%><TR><TD valign=top width=370px max-width=370px><DIV id=TRSide1></div></td><TD valign=top width=370px max-width=370px><DIV id=TRSide0></div></td></tr></table>';
				m+='</table></div>';
				if (tiletype == 51 && defnm != null) action = "PvP ATTACK";
				else if (tiletype == 51) action = "BARB CAMP ATTACK"
				else action = "WILD ATTACK";
				break;
		default: alert("Only attack and scout reports are supported for the moment...");return;
	}	
	popReport.getMainDiv().innerHTML = m;
	popReport.getTopDiv().innerHTML = '<DIV align=center><B>'+ action +' Report</b></DIV>';
	popReport.show(true);
	document.getElementById('PostToChat').addEventListener('click', function(){DispReport.PostChatReport(rptid);} , false);
	if (!link) document.getElementById('Delete').addEventListener('click', function(){DeletMyReport(rptid,unread,popReport);} , false);
	paintInfo(rslt, atknm, defnm, atkxcoord, atkycoord, xcoord, ycoord,side0AllianceName,side1AllianceName);
	paintTroops(rslt.fght);
	if (rslt.bonus) paintStats(rslt.bonus.mod);
	if (rslt.bonus) paintBonuses(rslt);
	if (rslt.loot) paintResources(rslt.loot,rslt.throneRoomDrop);
	if (rslt.tch) paintResearch(rslt);
	if (rslt.rsc) paintScoutResources(rslt.rsc);
	if (rslt.unts || rslt.frt) paintScoutTroops(rslt.unts,rslt.frt);
	if (rslt.blds) paintBuildings(rslt);
}


var Mightloss = 0;
var WoundedMight = 0;

function paintInfo (rslt, atknm, defnm, atkxcoord, atkycoord, defxcoord, defycoord,side0AllianceName,side1AllianceName){
	if (defnm == null) defnm = "Enemy";
	m = "<DIV><B>Attackers: </b> " + atknm + '&nbsp' + coordLink(atkxcoord,atkycoord);
	if (rslt.winner == 1) m+='<FONT color=red><B> Winner</b></font>';
	if (side1AllianceName && isNaN(side1AllianceName)) m+='<BR>Alliance: ' + side1AllianceName;
	m +='<BR>Knight Combat Skill: ' + rslt.s1KCombatLv;
	calcMightloss(rslt.fght,1)
	m +='<BR>Might lost: ' + addCommas(Mightloss);
	m +='<BR>Wounded might: ' + addCommas(WoundedMight);
	if (rslt.overwhelmed) m +='<BR>Troops got overwhelmed!!';
	document.getElementById('InfoSide1').innerHTML = m;
	m = "<DIV><B>Defenders: </b> " + defnm + '&nbsp' + coordLink(defxcoord,defycoord);
	if (rslt.winner == 0) m+='<FONT color=red><B> Winner</b></font>';
	if (side0AllianceName && isNaN(side0AllianceName)) m+='<BR>Alliance: ' + side0AllianceName;
	m +='<BR>Knight Combat Skill: ' + rslt.s0KCombatLv;
	calcMightloss(rslt.fght,0)
	m +='<BR>Might lost: ' + addCommas(Mightloss);
	m +='<BR>Wounded might: ' + addCommas(WoundedMight);
	m +='<BR>Rounds: ' + rslt.rnds;
	document.getElementById('InfoSide0').innerHTML = m;
}

function calcMightloss (fght,s){
	var killed = 0;
	Mightloss = 0;
	WoundedMight = 0;
	if (fght['s'+s] != undefined) {	
		for(y in unsafeWindow.unitcost) if (fght['s'+s]['u'+y.substr(3)] != undefined) {
			killed = fght['s'+s]['u'+y.substr(3)][0] - fght['s'+s]['u'+y.substr(3)][1];
			Mightloss += unsafeWindow.unitmight[y] * killed;
			if (fght['s'+s]['u'+y.substr(3)][2] == '?') WoundedMight = "?";
			else WoundedMight += unsafeWindow.unitmight[y] * fght['s'+s]['u'+y.substr(3)][2];
		}
		for(y in fortmight) if (fght['s'+s]['f'+y.substr(1)] != undefined) {
			killed = fght['s'+s]['f'+y.substr(1)][0] - fght['s'+s]['f'+y.substr(1)][1];
			Mightloss += fortmight[y] * killed;
			if (fght['s'+s]['f'+y.substr(1)][2] == '?') WoundedMight = "?";
			else WoundedMight += fortmight[y] * fght['s'+s]['f'+y.substr(1)][2];
		}
	}
}
function paintResources (loot,TR){
	var m = '<TABLE class=pbTab  style="width:100%;"><TR>';
	var what = ["gold","food","wood","stone","iron"]
	for (i=0;i<=4;i++) m+='<TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+ what[i] +'_30.png></td><TD>' + addCommas(loot[i])+'</td>';
	if (loot[6] > 0) m+='</tr><TR><TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png>' + addCommas(loot[6])+'</td>';
	for (var crest=1101; crest < 1116; crest++) if (loot[5][crest] == 1) m+='<TD><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/' + crest + '.png>' + crestname[crest] + '</td>';
	if (TR != undefined) m+='<TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/' + TR.faction + '/' + TR.faction + '_'+ TR.type +'_normal_1_'+ TR.quality+'.png></td>';
	m+='</tr></table>';;
	document.getElementById('rptResources').innerHTML = m;
}

function paintScoutResources (rsc){
	var m = '<TABLE class=pbTab  style="width:100%;"><TR>';
	var what = ["gold","food","wood","stone","iron"]
	for (i=1;i<=4;i++) m+='<TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/'+ what[i] +'_30.png></td><TD>' + addCommas(Math.round(rsc['r' + i]))+'</td>';
	m+='</tr></table>';
	document.getElementById('ScoutResources').innerHTML = m;
}


function paintTroops (fght){
	var m = "";
	var killed = 0;
	var Paintkilled = "";
	var PctWounded = 0;
	var PaintPctWounded ="";
	for(s=1;s>=0;s--){
		m = "No Troops Defended";
		if (fght['s'+s] != undefined) {	
			m = '<TABLE class=pbTab><TR><TD width=50px>&nbsp</td><TD width=75px>Fought</td><TD width=125>Survived</td><TD width=100px>Wounded</td>';
			for(y in unsafeWindow.unitcost) if (fght['s'+s]['u'+y.substr(3)] != undefined) {
				Paintkilled = "";
				PctWounded = 0;
				PaintPctWounded ="";
				killed = fght['s'+s]['u'+y.substr(3)][0] - fght['s'+s]['u'+y.substr(3)][1];
				if (killed > 0) Paintkilled = '<FONT color=red> ('+ addCommas(killed) +')</font>';
				if (fght['s'+s]['u'+y.substr(3)][2] != "?") PctWounded = (fght['s'+s]['u'+y.substr(3)][2] / fght['s'+s]['u'+y.substr(3)][0]) * 100;
				if (PctWounded > 0) PaintPctWounded = ' (' + Math.round(PctWounded) + '%)';
				m += '<TR><TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ y.substr(3) +'_30.jpg?6545></td><TD>' + addCommas(fght['s'+s]['u'+y.substr(3)][0]) + '</td><TD>' + addCommas(fght['s'+s]['u'+y.substr(3)][1]) + Paintkilled +'</td><TD>' + addCommas(fght['s'+s]['u'+y.substr(3)][2]) + PaintPctWounded + '</td></tr>';
			}
			for(y in unsafeWindow.fortcost) if (fght['s'+s]['f'+y.substr(3)] != undefined) {
				Paintkilled = "";
				PctWounded = 0;
				PaintPctWounded ="";
				killed = fght['s'+s]['f'+y.substr(3)][0] - fght['s'+s]['f'+y.substr(3)][1];
				if (killed > 0) Paintkilled = '<FONT color=red> ('+ addCommas(killed) +')</font>';
				if (fght['s'+s]['f'+y.substr(3)][2] != "?") PctWounded = (fght['s'+s]['f'+y.substr(3)][2] / fght['s'+s]['f'+y.substr(3)][0]) * 100;
				if (PctWounded > 0) PaintPctWounded = ' (' + Math.round(PctWounded) + '%)';
				m += '<TR><TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ y.substr(3) +'_30.jpg></td><TD>' + addCommas(fght['s'+s]['f'+y.substr(3)][0]) + '</td><TD>' + addCommas(fght['s'+s]['f'+y.substr(3)][1]) + Paintkilled +'</td><TD>' + addCommas(fght['s'+s]['f'+y.substr(3)][2]) + PaintPctWounded + '</td></tr>';
			}
			m +='</table>';
		}
		document.getElementById('TroopsSide'+s).innerHTML = m;
	}
}

function paintScoutTroops (unts,frt){
	var	m = "None. You may need to increase your Eagle Eyes research level to see more info.";
	var counter = 0;
	if (unts.length !=0 && frt.lengt !=0) {
		m = '<TABLE class=pbTab width=100%><TR>';
		for(y in unts) {
			counter++;
			if (counter == 7 || counter == 14) m+='</tr><TR>'
			if (unts.length !=0) m += '<TD width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ y.substr(1) +'_30.jpg?6545></td><TD>' + addCommas(unts[y]) + '</td>';
		}
		m+='</tr><TR>'
		for(y in frt){
			if (frt.length !=0) m += '<TD><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ y.substr(1) +'_30.jpg></td><TD>' + addCommas(frt[y]) +'</td>';
		}
		m +='</tr></table>';
	}
	document.getElementById('ScoutTroops').innerHTML = m;
}

function paintStats (mod){
	var m = '';
	var color = "black";	
	var diff = 0;
	var diffCont = "";
	for(s=1;s>=0;s--){
		m = '<TABLE class=pbTab width=80%>';
		for (y in unsafeWindow.unitcost) {
			var i = y.substr(3);		
			if (mod["s"+s] != undefined && mod["s"+s]['u'+i] != undefined) {
				m+='<TR><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ i +'_30.jpg?6545></td><TD>';
				for(k in mod["s"+s]['u'+i]){
					diff = 0;
					diffCont = "";
					if (mod['s'+s]['u'+i][k][0] < mod['s'+s]['u'+i][k][1]) {
						color = "green";
						diff = ((Math.round(mod['s'+s]['u'+i][k][1]) - Math.round(mod['s'+s]['u'+i][k][0])) / Math.round(mod['s'+s]['u'+i][k][0])) * 100;
						diffCont = ' (' + Math.round(diff) + '%)';
					}
					else if (mod['s'+s]['u'+i][k][0] > mod['s'+s]['u'+i][k][1]) {
						color="red";
						diff = ((Math.round(mod['s'+s]['u'+i][k][1]) - Math.round(mod['s'+s]['u'+i][k][0])) / Math.round(mod['s'+s]['u'+i][k][1])) * 100;
						diffCont = ' (' + Math.round(diff) + '%)';
					}
					else color="black";
					if (k == 'spd') m+='</td></tr><TR><TD>';
					if (mod['s'+s]['u'+i][k]) m+='<TD width=20px><FONT size=1><B>' + k + ':</b></td></font><TD><FONT size="1" color='+ color +'>' + addCommas(Math.round(mod['s'+s]['u'+i][k][1])) + diffCont + '</font></td>';
				}
			}
		}
		m += '</tr>';
		for (y in unsafeWindow.fortcost) {
			var i = y.substr(3);
			if (mod["s"+s] != undefined && mod["s"+s]['f'+i] != undefined) {
					m+='<TR><TD rowspan=2 width=30px><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ i +'_30.jpg></td><TD>';
					for(k in mod["s"+s]['f'+i]){
						diff = 0;
						diffCont = "";
						if (mod['s'+s]['f'+i][k][0] < mod['s'+s]['f'+i][k][1]) {
							color = "green";
							diff = ((Math.round(mod['s'+s]['f'+i][k][1]) - Math.round(mod['s'+s]['f'+i][k][0])) / Math.round(mod['s'+s]['f'+i][k][0])) * 100;
							diffCont = ' (' + Math.round(diff) + '%)';
						}
						else if (mod['s'+s]['f'+i][k][0] > mod['s'+s]['f'+i][k][1]) {
							color="red";
							diff = ((Math.round(mod['s'+s]['f'+i][k][1]) - Math.round(mod['s'+s]['f'+i][k][0])) / Math.round(mod['s'+s]['f'+i][k][1])) * 100;
							if (diff != "-Infinity") diffCont = ' (' + Math.round(diff) + '%)';
						}
						else color="black";
						if (k == 'spd') m+='</td></tr><TR><TD>';
						if (mod['s'+s]['f'+i][k]) m+='<TD width=20px><FONT size="1"><B>' + k + ':</b></td></font><TD><FONT size="1" color='+ color +'>' + addCommas(Math.round(mod['s'+s]['f'+i][k][1])) + diffCont + '</font></td>';
					}
			}
		}
		m +='</tr></table>';
		if (mod["s"+s] && mod["s"+s]['b19']) m+='<BR>Castle Life: ' + addCommas(mod["s"+s]['b19']['hp'][0]) +' / ' + addCommas(mod["s"+s]['b19']['hp'][1]);
		document.getElementById('StatsSide'+s).innerHTML = m;
	}
}

function paintBonuses (rslt){
	var Items = "";
	var Tech = "";
	var TR = "";
	var translate = {"hp":"Life","atk":"Attack","def":"Defense","spd":"Speed","rng":"Range","ld":"Load","ic":"Improved Cartography","id":"Improved Defenses","sr":"Strengthen Ranks","if":"Improved Fletching"};
	for (s=1;s>=0;s--){
		Items = '<TABLE class=pbTab>';
		if (rslt['s' + s + 'atkBoost'] != 0 && rslt['s' + s + 'atkBoost']) Items+='<TR><TD>Attack boost: </td><TD>' + Math.round(rslt['s' + s + 'atkBoost']*100) + '%</td></tr>';
		if (rslt['s' + s + 'defBoost'] != 0 && rslt['s' + s + 'defBoost']) Items+='<TR><TD>Defense boost: </td><TD>' + Math.round(rslt['s' + s + 'defBoost']*100) + '%</td></tr>';
		if (rslt['s' + s + 'lifeBoost'] != 0 && rslt['s' + s + 'lifeBoost']) Items+='<TR><TD>Life boost: </td><TD>' + Math.round(rslt['s' + s + 'lifeBoost']*100) + '%</td></tr>';
		if (rslt['s' + s + 'guardianAtkBoost'] != undefined) Items+='<TR><TD>Guardian Attack boost: </td><TD>' + Math.round(rslt['s' + s + 'guardianAtkBoost']*100) + '%</td></tr>';
		if (rslt['s' + s + 'guardianDefBoost'] != undefined) Items+='<TR><TD>Guardian Defense boost: </td><TD>' + Math.round(rslt['s' + s + 'guardianDefBoost']*100) + '%</td></tr>';
		Items += '</table>';		
		Tech = '<TABLE class=pbTab>';
		for(y in rslt.bonus.tch['s' + s]) Tech+='<TR><TD width=75px>' + translate[y] + '</td><TD>' + Math.round(rslt.bonus.tch['s' + s][y]*100) + '%</td>	</tr>';
		if (rslt.bonus.tch2) for(y in rslt.bonus.tch2['s' + s]) Tech+='<TR><TD width=150px>' + translate[y] + '</td><TD>' + Math.round(rslt.bonus.tch2['s' + s][y]*100) + '%</td></tr>';
		Tech += '</table>';		
		TR = '<TABLE class=pbTab>';
		for(y in rslt['s' + s + 'ThroneRoomBoosts']) TR+='<TR><TD width=50px>' + rslt['s' + s + 'ThroneRoomBoosts'][y] + '%</td><TD>' + unsafeWindow.cm.thronestats["effects"][y]["1"] + '</td></tr>';
		TR += '</table>';		
		document.getElementById('ItemsSide'+s).innerHTML = Items;
		document.getElementById('TechSide'+s).innerHTML = Tech;
		document.getElementById('TRSide'+s).innerHTML = TR;
		
	}	
	
}

function paintResearch (rslt){
		Research = '<TABLE class=pbTab>';
		for (i=1;i<=17;i++) {
			if (i!=7) if(rslt.tch) Research +='<TR><TD width=175px>' + unsafeWindow.techcost['tch'+i][0] + '</td><TD>' + rslt.tch['t'+i] +'</td>';
		}
		for (i=1;i<=6;i++) {
			if(rslt.tch2) Research +='<TR><TD width=175px><B>' + unsafeWindow.techcost2['tch'+i][0] + '</td><TD>' + rslt.tch2['t'+i] +'</b></td>';
		}
		Research += '</table>';		
		document.getElementById('Research').innerHTML = Research;
}

function paintBuildings (rslt){
		Buildings = '<TABLE class=pbTab>';
		for (y in unsafeWindow.buildingcost) if (rslt.blds['b'+ y.substr(3)]) {
			i = y.substr(3);
			Buildings +='<TR><TD width=175px>' + unsafeWindow.buildingcost['bdg'+i][0] + '</td><TD>' + rslt.blds['b'+i] +'</td>';
		}
		Buildings += '</table>';		
		document.getElementById('Buildings').innerHTML = Buildings;
}

function DeletMyReport (rptid, isUnread, popReport){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.s0rids = rptid;
    params.s1rids = '';
    params.cityrids = '';
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (transport) {
      	var rslt = eval("(" + transport.responseText + ")");
      	if (rslt.ok) {
      		if (isUnread){
      			unsafeWindow.seed.newReportCount = parseInt(Seed.newReportCount) - 1;
          		unsafeWindow.messages_notify_bug()
      		}
      		unsafeWindow.pageNavigatorModel.gotoPage(1);
            unsafeWindow.Messages.listReports();
		    popReport.show(false);
      	}   
      },
      onFailure: function () {
      },
    });
 }

var battleReports = {
  init : function (){
    var t = battleReports; 
    t.getReportDisplayFunc = new CalterUwFunc ('getReportDisplay', [['return K.join("")', 'var themsg=K.join(""); themsg=getReportDisplay_hook(themsg, arguments[1]); themsg=getReportDisplay_hookz(themsg, arguments[1]); return themsg']]); //Alliance report battle rounds function
    unsafeWindow.getReportDisplay_hook = t.hook;
    unsafeWindow.getReportDisplay_hookz = t.hookz;
    t.getReportDisplayFunc.setEnable (true);
    t.renderBattleReportFunc = new CalterUwFunc ('Messages.viewMarchReport', [[/\$\("modal_msg_list"\)\.innerHTML\s*=\s*cm\.MarchReportController\.getMarchReport\(c,\s*w\)/, 'var msg = cm.MarchReportController.getMarchReport(c, s); $("modal_msg_list").innerHTML = renderBattleReport_hook(msg,c,s);']]); //March reports battle rounds function
    unsafeWindow.renderBattleReport_hook = t.hook2;
    t.renderBattleReportFunc.setEnable (true);
    unsafeWindow.deleteAreport = t.e_deleteReport;
    unsafeWindow.MoreReport = t.e_MoreReport;
    unsafeWindow.PostReport = t.e_PostReport;
	},


  isRoundsAvailable : function (){
    var t = battleReports; 
    return t.getReportDisplayFunc.isAvailable() || t.renderBattleReportFunc.isAvailable();
  },
  
  e_deleteReport : function (rptid){
    var t = battleReports; 
    t.ajaxDeleteMyReport (rptid);
  },
  
  e_MoreReport : function (rptid,side){
    var t = battleReports; 
    alert('WIP ;)');
  },
  
  e_PostReport : function (rptid){
      var msg = 'Report No: ' + rptid; 
      sendChat ("/a "+  msg);
  },
  
  SendChat:function(name,mess) {
    	var inp=document.getElementById('mod_comm_input');
    	inp.value="@"+name+' '+mess;
    	unsafeWindow.Chat.sendChat();
  },
      
  ajaxDeleteMyReport : function (rptid, isUnread, side, isCityReport, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.s0rids = rptid;
    params.s1rids = '';
    params.cityrids = '';
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok && isUnread){
          unsafeWindow.seed.newReportCount = parseInt(seed.newReportCount) - 1;
          unsafeWindow.messages_notify_bug()
        }    
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },
  
  hookz : function (msg, rslt) {
    msg = msg.replace (/(\bReport\sNo\:\s([0-9]+))/g, '<a onclick=\'ptChatReportClicked($2,0,999)\'>$1</a>');
  return msg;
  },

  hook2 : function (msg, args, rslt){
    if (rslt.rnds && Options.dispBattleRounds){
      msg = msg.replace (/<\/ul>.*\s*<\/div>.*\s*<div class="unitsContainer">/im, '<li><span class=\'label\'>Rounds: </span><span class=\'value\'>'+ rslt.rnds +'</span></li></ul></div><div class="unitsContainer">');
    }
	if (Options.reportDeleteButton){
		msg = msg.replace(/Reports<\/span><\/a>/im, 'Reports</span></a><a class=\'button20\' onclick=\'PostReport('+args[0]+',false)\'><span>Post To Chat</span></a>'); //Post to Chat button
		msg = msg.replace(/Reports<\/span><\/a>/im, 'Reports</span></a><a class=\'button20\' onclick=\'MoreReport('+args[0]+','+args[1]+',false)\'><span>More</span></a>'); //More button
		msg = msg.replace(/Reports<\/span><\/a>/im, 'Reports</span></a><a class=\'button20\' onclick=\'deleteAreport('+args[0]+',false)\'><span>'+unsafeWindow.g_js_strings.commonstr.deletetx+'</span></a>'); //Delete button
	}
    return msg;
  },
  hook : function (msg, rslt){
    if (rslt.rnds && Options.dispBattleRounds) msg = msg.replace (/(Attackers <span.*?)<\/div>/im, '$1<BR>Rounds: '+ rslt.rnds +'</div>');
    return msg;
  },
}

var AttackDialog = {
  init : function (){
    var t = AttackDialog;
    t.modal_attackFunc = new CalterUwFuncTools ('modal_attack', [[/}\s*$/, '; attackDialog_hook(); }']]);
    unsafeWindow.attackDialog_hook = t.modalAttackHook;
    t.modal_attackFunc.setEnable (true);
    AttackDialog.isKnightSelectAvailable();
  },  
  setEnable : function (){},
  isKnightSelectAvailable : function (){
    var t = AttackDialog;
    return t.modal_attackFunc.isAvailable();
  },
  isAttackCityPickerAvailable : function (){
    var t = AttackDialog;
    return t.modal_attackFunc.isAvailable();
  },
  modalAttackHook : function (){
    var t = AttackDialog;
    for (var i=1; i<6; i++) document.getElementById('modal_attack_tab_'+ i).addEventListener('click', t.e_changeMarchType, false); 
    setTimeout (t.initCityPicker, 0);        
  },
  
  initCityPicker : function (){
    var t = AttackDialog;
    var div = document.getElementById('modal_attack_target_numflag'); // as of KofC version 96;
    var mySpan;
    if (div) {
      div.parentNode.innerHTML += ' &nbsp; <SPAN id=modal_attack_citybuts></span>';
    } else {
      var span = document.getElementById('modal_attack_target_coords');   // KofC version 116+;
      span.parentNode.parentNode.firstChild.innerHTML += ' &nbsp; <SPAN id=modal_attack_citybuts></span>';
    }
    new CdispCityPicker ('ptatp', document.getElementById('modal_attack_citybuts'), false, t.e_CityButton);
    var cityIdx = Cities.byID[unsafeWindow.currentcityid].idx;
    thisCityBut = document.getElementById('ptatp_'+ cityIdx);
    thisCityBut.style.opacity = '0.5';
    thisCityBut.disabled = true;
    if (document.getElementById('modal_attack_tab_4').className=='selected' || document.getElementById('modal_attack_tab_3').className=='selected')   // don't do for attack or scout
      document.getElementById('modal_attack_citybuts').style.display = 'none';
  },
  
  e_CityButton : function (city){
    document.getElementById('modal_attack_target_coords_x').value = city.x;
    document.getElementById('modal_attack_target_coords_y').value = city.y;
    unsafeWindow.modal_attack_update_time();
  },
      
  e_changeMarchType : function (evt){
    var t = AttackDialog;
    var marchType = parseInt(evt.target.id.substr(17));  
      if (marchType==3 || marchType==4) document.getElementById('modal_attack_citybuts').style.display = 'none';
      else document.getElementById('modal_attack_citybuts').style.display = 'inline';
      var knightVal = 0;
      var selector = document.getElementById('modal_attack_knight'); 
      if (selector.length>1 && (marchType==4 || marchType==2)) knightVal = 1;
      selector.selectedIndex = knightVal; 
  },  
}


var CoordBox = {
  init : function (){
    var t = CoordBox;
    t.boxDiv = searchDOM (document.getElementById('maparea_map'), 'node.className=="mod_coord"', 3, false);
    t.setEnable (Options.mapCoordsTop);
  },
  setEnable : function (tf){
    var t = CoordBox;
    if (t.boxDiv == null)
      return;
    if (tf)
      t.boxDiv.style.zIndex = '100000';
    else
      t.boxDiv.style.zIndex = '10011';
  }, 
  isAvailable : function (){
    var t = CoordBox;
    return !(t.boxDiv==null);
  }, 
};

var AllianceReports = {
  checkPeriod : 300,
  allianceNames : [],
  saveArfunc : unsafeWindow.allianceReports,

  init : function (){
    t = AllianceReports;
    t.enable (true);
    t.marvFunc = new CalterUwFuncTools ('modal_alliance_report_view', [['getReportDisplay', 'getReportDisplay_hook2']]);
    t.memListFunc = new CalterUwFuncTools ('membersInfo', [['commonstr.might','commonstr.might + "</td><td class=colcities>" + g_js_strings.commonstr.cities + "</td><td class=collast>" + g_js_strings.membersInfo.lastonline'],['memberInfo[key].prestige)', 'memberInfo[key].prestige)+ "</td>");memhtml.push("<td class=colcities>" + memberInfo[key].cities + "</td>");memhtml.push("<td class=collast>" + memberInfo[key].lastLogin']]);
    unsafeWindow.getReportDisplay_hook2 = t.getReportDisplayHook;
    unsafeWindow.getmembersInfo_hook = t.getMembersInfoHook;
    t.marvFunc.setEnable (true);
    t.enable_viewmembers(true);
  },
   
  getReportDisplayHook : function (a, b){
    var x = '';
    try {
      x = unsafeWindow.getReportDisplay(a,b);  
    } catch (e){
      x = 'Error formatting report: '+ e;
    }
    return x;
  },
  
  enable_viewmembers : function (tf){
    t = AllianceReports;
    t.memListFunc.setEnable (tf);
  },
  
  enable : function (tf){
    t = AllianceReports;
    if (tf) unsafeWindow.allianceReports = t.myAllianceReports;
    else unsafeWindow.allianceReports = t.saveArfunc;
  },
  
  myAllianceReports : function (pageNum){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    if (pageNum) params.pageNo = pageNum;
    params.group = "a";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {displayReports (rslt.arReports, rslt.arPlayerNames, rslt.arAllianceNames, rslt.arCityNames, rslt.totalPages);},
      onFailure: function (rslt) {},
    }, false);

    function displayReports (ar, playerNames, allianceNames, cityNames, totalPages){
      var msg = new Array();
      var myAllianceId = getMyAlliance()[0];
      msg.push ("<STYLE>.msgviewtable tbody .myCol div {margin-left:5px; overflow:hidden; white-space:nowrap; color:#000}\
            .msgviewtable tbody .myHostile div {font-weight:600; color:#600}\
            .msgviewtable tbody .myGray div {color:#666}\
            .msgviewtable tbody .myRein div {color:#050}\
            .msgviewtable tbody .myWarn div {font-weight:600; color:#442200}\
            </style>");
      msg.push("<div class='modal_msg_reports'>");
      var rptkeys = unsafeWindow.Object.keys(ar);
      if (matTypeof(ar) != 'array') {
        if (Options.allowAlterAR) msg.push("<div id='modal_alliance_reports_tablediv' class='modal_msg_list'><table width=675 cellpadding='0' cellspacing='0' class='msgviewtable reportviewtable alliancetable'>");
        else msg.push("<div id='modal_alliance_reports_tabledivNKA' class='modal_msg_list'><table width=675 cellpadding='0' cellspacing='0' class='msgviewtable reportviewtable alliancetable'>");
        msg.push("<thead><tr><td width=105>Date</td><td width=40>Type</td><td width=150>Attacker</td><td>Target</td><td>View</td></tr></thead><tbody>");
        for (var i = 0; i < rptkeys.length; i++) {
          var rpt = ar[rptkeys[i]];
          var colClass = '"myCol"';
          rpt.marchType = parseInt(rpt.marchType);
          rpt.side0AllianceId = parseInt(rpt.side0AllianceId);
          var targetDiplomacy = getDiplomacy (rpt.side0AllianceId);
          if (rpt.marchType == 2){
            colClass = '"myCol myRein"';
          } else if (rpt.side1AllianceId != myAllianceId){
            colClass = '"myCol myHostile"';
          } else {
            if (parseInt(rpt.side0TileType) < 50){          // if wild
              if (parseInt(rpt.side0PlayerId) == 0) colClass = '"myCol myGray"';
              else colClass = '"myCol myWarn"';
            } else if (parseInt(rpt.side0PlayerId) == 0) {   // barb
              colClass = '"myCol myGray"';
            } else {
              if (targetDiplomacy == 'friendly') colClass = '"myCol myWarn"';
            }
          }
          msg.push ('<tr valign=top');
          if (i%2 == 0) msg.push(" class=stripe");
          msg.push("><TD class="+ colClass +"><div>");
          msg.push(unsafeWindow.formatDateByUnixTime(rpt.reportUnixTime));
          msg.push ('<BR>Rpt #');
          msg.push (rpt.reportId);          
          msg.push("</div></td><TD class="+ colClass  +"><div>");
          if (rpt.marchType == 1) msg.push (unsafeWindow.g_js_strings.commonstr.transport);
          else if (rpt.marchType == 3) msg.push (unsafeWindow.g_js_strings.commonstr.scout);
          else if (rpt.marchType == 2) msg.push ('Reinf');
          else msg.push (unsafeWindow.g_js_strings.commonstr.attack);

          // attacker ...
          msg.push ("</div></td><TD class="+ colClass +"><div>");
          if (parseInt(rpt.side1PlayerId) != 0) msg.push(escape(playerNames["p" + rpt.side1PlayerId]))
          else msg.push ('?Unknown?');
            msg.push (' ');
            msg.push (coordLink(rpt.side1XCoord, rpt.side1YCoord));
            msg.push ('<BR>');
          
          if (rpt.side1AllianceId != myAllianceId){
            msg.push (allianceNames['a'+rpt.side1AllianceId]);
            msg.push (' (');
            msg.push (getDiplomacy(rpt.side1AllianceId));
            msg.push (')');
          } else {
            msg.push ('<BR>');
          }
          msg.push ('</div></td>');

          // target ...
          msg.push ("<TD class="+ colClass  +"><DIV>");
          var type = parseInt(rpt.side0TileType);

          if (type < 50){                              // wild
            msg.push(unsafeWindow.g_mapObject.types[type].toString().capitalize());
            msg.push(" Lvl " + rpt.side0TileLevel)
            if (parseInt(rpt.side0PlayerId) != 0) {   // IF OWNED, show owner ...
              msg.push (' [');
              msg.push (escape(playerNames["p" + rpt.side0PlayerId]));
              msg.push ('] ');
            }
          } else {
            if (parseInt(rpt.side0PlayerId) == 0) {   //  barb
              msg.push(unsafeWindow.g_js_strings.commonstr.barbariancamp);
              msg.push(" Lvl " + rpt.side0TileLevel)
            } else {        // city
              msg.push (escape(playerNames["p" + rpt.side0PlayerId]));
              msg.push (' - ');
              msg.push (cityNames['c'+ rpt.side0CityId]);
            }
          }
          msg.push (' ');
          msg.push (coordLink(rpt.side0XCoord, rpt.side0YCoord));
          if (rpt.side0AllianceId!=0 && rpt.side0AllianceId!=myAllianceId){
            msg.push ('<BR>');
            msg.push (allianceNames['a'+rpt.side0AllianceId]);
            msg.push (' (');
            msg.push (targetDiplomacy);
            msg.push (')');
          }

          // 'view report' link ...
          //if (Options.allowAlterAR) 
          
          //msg.push("</div></td><TD class="+ colClass  +"><div><a onclick=' modal_alliance_report_view(\"");   // ONCLICK ???
          //else
          msg.push("</div></td><TD class="+ colClass  +"><div><a onclick=' $(\"modal_alliance_reports_tabledivNKA\").id=\"modal_alliance_reports_tablediv\"; modal_alliance_report_view(\"");   // ONCLICK ???
          msg.push(rpt.reportId);
          msg.push('",');
          if (parseInt(rpt.side1AllianceId) == parseInt(Seed.allianceDiplomacies.allianceId)) msg.push(1);
          else msg.push(0);
          msg.push(",");
          msg.push(rpt.side0TileType);
          msg.push(",");
          msg.push(rpt.side0TileLevel);
          msg.push(",");
          msg.push(rpt.side0PlayerId);
          msg.push(',"');
          if (parseInt(rpt.side0PlayerId) != 0) msg.push(escape(playerNames["p" + rpt.side0PlayerId]));
          else msg.push(unsafeWindow.g_js_strings.commonstr.enemy);
          msg.push('","');
          if (parseInt(rpt.side0PlayerId) != 0) msg.push(escape(playerNames["g" + rpt.side0PlayerId]));
          else msg.push(0)
          msg.push('","');
          if (parseInt(rpt.side1PlayerId) > 0) msg.push(escape(playerNames["p" + rpt.side1PlayerId]));
          msg.push('","');
          if (parseInt(rpt.side1PlayerId) != 0) msg.push(escape(playerNames["g" + rpt.side1PlayerId]));
          msg.push('",');
          msg.push(rpt.marchType);
          msg.push(",");
          msg.push(rpt.side0XCoord);
          msg.push(",");
          msg.push(rpt.side0YCoord);
          msg.push(",");
          msg.push(rpt.reportUnixTime);
          msg.push(",");
          if (parseInt(rpt.reportStatus) == 2) msg.push(1);
          else msg.push(0);
          if (rpt.side1XCoord) {
            msg.push(",");
            msg.push(rpt.side1XCoord);
            msg.push(",");
            msg.push(rpt.side1YCoord)
          } else {
            msg.push(",,");
          }
          msg.push(");return false;'>View</a></div></td></tr>");
        }
        msg.push("</tbody></table></div>");
      }
      msg.push("</div><div id='modal_report_list_pagination'></div>");
      document.getElementById('allianceContent').innerHTML = msg.join("");
      if (pageNum) unsafeWindow.ctrlPagination("modal_report_list_pagination", totalPages, "allianceReports", pageNum)
       else unsafeWindow.ctrlPagination("modal_report_list_pagination", totalPages, "allianceReports")
    }
  },

};


var DispReport = {
  init : function (){
    var t = DispReport;
    t.modal_InboxFunc = new CalterUwFuncTools ('modal_messages_listshow', [['msghtml.join("");', 'msghtml.join("");dispInbox_hook(rslt,boxType,msghtml);']]);
    unsafeWindow.dispInbox_hook = t.ModalInboxHook;
    t.modal_InboxFunc.setEnable (true);
    t.modal_RptFunc = new CalterUwFuncTools ('Messages.handleListReports', [['n.join("");', 'n.join("");dispRpt_hook(l,n);']]);
    unsafeWindow.dispRpt_hook = t.ModalReportListHook;
    t.modal_RptFunc.setEnable (true);
  },
  setEnable : function (tf){
    var t = DispReport;
    t.modal_InboxFunc.setEnable (tf);
  },
  isDispReportAvailable : function (){
    var t = DispReport;
    return t.modal_InboxFunc.isAvailable();
  }, 
  ModalInboxHook : function (rslt,boxType,msghtml){
    var t = DispReport;
    /*if(boxType == 'inbox'){
    msgBody = document.getElementByClass('modal_msg_list');
    var a = document.createElement('a');
      a.className='buttonDown20';
      a.innerHTML='<span>Delete Gift Report</span>';
      //a.innerHTML = '';
      //<SPAN onclick="PTpd(this, '+ u.userId +')"><A>'+unsafeWindow.g_js_strings.modaltitles.memberdetails+'</a>
      //a.innerHTML='<onclick="checkinbox();return false;""><A>Delete Gift messages</a>';
      //a.innerHTML = '<a class="buttonDown20" onclick="checkinbox(this);return;false;"><span>Delete gift messages</span>';
      a.style.cssText = 'position:absolute;left:22px';
      a.addEventListener('click', t.checkinbox, false);
    var div = document.createElement('span');
    div.appendChild(a);
    msgBody.appendChild(div);
    var mml = document.getElementById('modal_msg_list');
    if (mml != null)
      mml.style.minHeight = '100px';
  }*/
  },
  checkinbox : function(){
    var t = DispReport;
    var body = document.getElementById('tbl_messages');
    var trs=body.getElementsByTagName('tr');
    var reports = [];
    for(var i=0; i<trs.length; i++){
      var tds = trs[i].getElementsByTagName('td');
      for(var j=0; j<tds.length; j++){
      if(tds[j].className == 'chkcol') var checkbox = tds[j];
      if(tds[j].className == 'nmcol') var sender = tds[j];   
      if(tds[j].className == 'subjcol') var subject = tds[j];    
    }
    reports.push({checkbox:checkbox,sender:sender,subject:subject});
  }
  t.parseGiftReport(reports);
  },
  parseGiftReport : function(rpts){
    var t = DispReport;
    for(var i=0; i<rpts.length; i++) if(rpts[i].subject.innerHTML.indexOf('New Gift Received!') >= 0 && rpts[i].sender.innerHTML.indexOf('Kingdoms Of Camelot') >= 0) rpts[i].checkbox.firstChild.checked = true;  
    unsafeWindow.messages_action("delete","tbl_messages"); 
  },
  ModalReportListHook : function (rslt, msghtml){
    var t = DispReport;
    unsafeWindow.PopupReport = ReportFetch;
    unsafeWindow.PostChatReport = t.PostChatReport;
    if(rslt.ok){
    var body = document.getElementById('modal_msg_reports_tablediv');
      var trs=body.getElementsByTagName('tr');
      for(var i=0; i<trs.length; i++){
      var tds = trs[i].getElementsByTagName('td');
      for(var j=0; j<tds.length; j++){
        if(tds[j].className == 'chkcol') var checkbox = tds[j]; 
        if(tds[j].className == 'nmcol'){
          var type = tds[j].innerHTML;
          type = type.replace("<div>","");
          type = type.replace("</div>","");
        }
        if(tds[j].className == 'subjcol'){
          var original = tds[j].innerHTML;
          var target = "";
          original = original.replace("<div>","");
          original = original.replace("</div>","");
          var popup = original.replace("View Report","Pop-up");
          popup = popup.replace("Messages.viewMarchReport","PopupReport");
          var chat = original.replace("View Report","Post");
          chat = chat.replace("Messages.viewMarchReport","PostChatReport");       
          var newContent = original + " | " + popup + " | " + chat;
          var test = popup.replace("<a onclick=\"PopupReport(","");
          test = test.replace(");return false;\">Popup</a>","");
          test = test.replace(/&quot;/g,"");
          var info = test.split(",")
          var notBarb = true;
          if (info[1] == 1 && info[5] == "Enemy") notBarb = false;
          var attack = false;
          if (info[9] == 3 || info[9] == 4) attack = true;
          if (notBarb && attack) tds[j].innerHTML = "<DIV>" + newContent + "</div>";
          if (info[5] != undefined && info[5] != "Enemy") target = ' / (' + info[5] + ')';
        }
      }
      for(var j=0; j<tds.length; j++) if(tds[j].className == 'nmcol') tds[j].innerHTML = "<DIV>" + type + target + '</div>';
    }
  }
  },
  PostChatReport : function(rpts){
    var t = DispReport;
    var msg = 'Report No: ' + rpts; 
    sendChat ("/a "+  msg);
  },
  checkreportlist : function(){
    var t = DispReport;
    var body = document.getElementById('modal_msg_reports_tablediv');
    var trs=body.getElementsByTagName('tr');
    var reports = [];
    for(var i=0; i<trs.length; i++){
      var tds = trs[i].getElementsByTagName('td');
      for(var j=0; j<tds.length; j++){
        if(tds[j].className == 'chkcol') var checkbox = tds[j];  
        if(tds[j].className == 'nmcol') var type = tds[j];  
        if(tds[j].className == 'subjcol') var view = tds[j];
      }
      reports.push({checkbox:checkbox,type:type,view:view});
    }
    t.parseBarbReport(reports);
  },
  
  parseBarbReport : function(rpts){
    var t = DispReport;
    var regex = /Messages.viewMarchReport\((["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),("[^"]+"),("[^"]+"),("[^"]+"),("[^"]+"),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+),(["0-9]+)\)/;
    for(var i=0; i<rpts.length; i++){
    var m = regex.exec(rpts[i].view.innerHTML);
    if(m){
      if(m[6]==m[8] && m[7]==m[9]){ //Source and target id the same.
        // continue; //Infer transport to self
      } else if(m[5] != 0) {
        continue;
      }
      rpts[i].checkbox.firstChild.checked = true;
    }
  }
  unsafeWindow.Messages.deleteCheckedReports();
  }

};

var OutgoingMarches = {
	active:false,	
	init: function(){
		var t = OutgoingMarches;
		unsafeWindow.cancelMarch = t.butcancelmarch;
		unsafeWindow.pr56Recall = t.butRecall;
    	unsafeWindow.r8x6Home = t.butSendHome;
    	unsafeWindow.button_sacrifice = t.doSacrificeQ;
		paint = new pbPopup ('pbmarches', 50, 50, 1100, 550, true, OutgoingMarches.close);
		paint.centerMe (mainPop.getMainDiv);
		paint.getMainDiv().innerHTML = '<DIV><INPUT id=MarchingRaids type=checkbox checked=true>&nbspHide Raids.</div><DIV id=marchesBody style="height:500px; max-height:500px	; max-width:1100px; overflow:auto"></div>';
		paint.getTopDiv().innerHTML = "<CENTER><b>Outgoing Marches</b></center>";
		if (OutgoingMarches.active){
			paint.show(false);
			OutgoingMarches.active=false;
		} else {
			paint.show(true);
			OutgoingMarches.active=true;
		}	
	},
	show: function(){
		var t = OutgoingMarches;
		var updatemarch = Seed.queue_atkp;
		var m='<TABLE id=pdmarches cellSpacing=10 class=pbTab>';
     	for (var c=0; c< Seed.cities.length;c++) {
	        cityname = Seed.cities[c][1];
	        cityID = 'city' + Seed.cities[c][0];    
	        number=0;         
	        var Counter=0;
	        var check = true;
	        for (k in Seed.queue_atkp[cityID]) if (Seed.queue_atkp[cityID].length !=0) if (parseInt(Seed.queue_atkp[cityID][k]["marchType"])!=9) Counter++;
	        if (document.getElementById('MarchingRaids').checked && Counter==0) check=false;
	        if (Seed.queue_atkp[cityID].length !=0 && check) m+= '<TR><TD colspan=5 style=\'background: #335577;\' align=center><B><FONT color=white>' + cityname +': </font></b></td></tr>';
	          for (k in Seed.queue_atkp[cityID]){
	          if (Seed.queue_atkp[cityID].length !=0) {
	              var marchID = new String(k);
	              marchID = marchID.substr(1);
	              var marchType = parseInt(Seed.queue_atkp[cityID][k]["marchType"]);
	              if (document.getElementById('MarchingRaids').checked && marchType ==9) continue;
	              var marchStatus = parseInt(Seed.queue_atkp[cityID][k]["marchStatus"]);
	              var now = unixTime();
	              cityTo = null;
	              number++;
	              var icon, status, type, cityTo, knight, marchtime;          
	              for (var i=0; i<Seed.cities.length;i++) if (Seed.cities[i][2] == Seed.queue_atkp[cityID][k]["toXCoord"] && Seed.cities[i][3] == Seed.queue_atkp[cityID][k]["toYCoord"]) cityTo = Seed.cities[i][1];
	              var destinationUnixTime = Seed.queue_atkp[cityID][k]["destinationUnixTime"] - now;
	              var returnUnixTime = Seed.queue_atkp[cityID][k]["returnUnixTime"] - now;
	              var encampedUnixTime = now - Seed.queue_atkp[cityID][k]["destinationUnixTime"];
	              var restingUnixTime = now - Seed.queue_atkp[cityID][k]["returnUnixTime"];
	              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] > now) marchtime = timestr(destinationUnixTime, true);
	               else marchtime = timestr(returnUnixTime, true);
	              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] < now && marchType == 2) marchtime = timestr(encampedUnixTime, true);
	              if (Seed.queue_atkp[cityID][k]["returnUnixTime"] < now && marchType == 9) marchtime = timestr(restingUnixTime, true);
	              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] < now || marchStatus == 8) type = "returning";
	               else type = "going";
	            if(Seed.queue_atkp[cityID][k]["destinationUnixTime"] < now){
	              if (marchStatus == 8) marchtime = timestr(returnUnixTime, true);
	              if (type =="returning" && marchType == 2 && marchStatus != 2) marchtime = timestr(returnUnixTime, true);
	              if (type =="returning" && marchType == 4 && marchStatus == 2) marchtime = timestr(returnUnixTime, true);
	              if (marchStatus == 2 && marchType !=2) marchtime = timestr(returnUnixTime, true);
	            }
	            if (parseInt(Seed.queue_atkp[cityID][k]["marchType"]) == 4 && marchStatus == 2) marchtime = timestr(destinationUnixTime, true);;
	            if (type =="returning" && marchType != 2) marchType = 8;
	            if (type =="returning" && marchType == 2 && marchStatus == 2) marchType = 102;
	            if (type =="returning" && marchType == 2 && marchStatus != 2) marchType = 8;
	            if (marchStatus == 3) marchType = 103;
	            if (marchStatus == 4) marchType = 104;
	          
	          
	              if (parseInt(Seed.queue_atkp[cityID][k]["marchType"]) == 4 && marchStatus == 2) {
		              marchType = 102;
		              marchtime = timestr(encampedUnixTime, true)
	              }
	  
	              switch (marchType) {
	                case 1: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/transporting.jpg";status=unsafeWindow.g_js_strings.commonstr.transport;break;
	                case 2: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/reinforce.jpg";status=unsafeWindow.g_js_strings.commonstr.reinforce;break;
	                case 3: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/scouting.jpg";status=unsafeWindow.g_js_strings.commonstr.scout;break;
	                case 4: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg";status=unsafeWindow.g_js_strings.commonstr.attack;break;
	                case 5: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/transporting.jpg";status=unsafeWindow.g_js_strings.commonstr.reassign;break;
	                case 8: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/returning.jpg";status=unsafeWindow.g_js_strings.commonstr.returning;break;
	                case 9: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg";status=unsafeWindow.g_js_strings.commonstr.raid;break;
	                case 10: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg";status=unsafeWindow.g_js_strings.commonstr.attack;break;
	                case 102: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/reinforce.jpg";status=unsafeWindow.g_js_strings.commonstr.encamped;break;
	                case 103: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/autoAttack/raid_stopped_desat.png";status=unsafeWindowg_js_strings.attack_generatequeue.raidstopped;break;
	                case 104: icon="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/autoAttack/raid_resting.png";status=unsafeWindow.g_js_strings.attack_generatequeue.raidresting;break;
	              } 

	              if (Seed.queue_atkp[cityID][k]["knightId"] !=0){
	                for (i in Seed.knights[cityID]) if (i == ("knt" + Seed.queue_atkp[cityID][k]["knightId"]) ) knight = Seed.knights[cityID][i]["combat"];
	              } else knight = null;
	              
	              m += '<TR><TD>'+ number +'</td>';
	             if (status=="Encamped" && !t.isMyself(Seed.queue_atkp[cityID][k].fromPlayerId)) m += '<TD><A onclick="r8x6Home('+ marchID +')"><img src='+ icon +'></a></td><TD width=25px><div id="skull'+marchID+'"></div></td>';
	              else if (status=='Encamped' && t.isMyself(Seed.queue_atkp[cityID][k].fromPlayerId)) m += '<TD><A onclick="pr56Recall('+ marchID +')"><img src='+ icon +'></a></td><TD width=25px><div id="skull'+marchID+'"></div></td>';
	              else if(status=='Returning' || status=="Stopped" || status=="Resting") m += '<TD><img src='+ icon +'></td><TD width=25px><div id="skull'+marchID+'"></div></td>';
	             else m += '<TD><A onclick="cancelMarch('+ marchID +')"><img src='+ icon +'></a></td><TD width=25px><div id="skull'+marchID+'"></div></td>';
	              m += '<TD width="40px">'+ status +'</td>';
	              m += '<TD>'+ marchtime +'</td>';
	              if (cityTo == null) m += '<TD style="padding-right:10px;">'+ coordLink(Seed.queue_atkp[cityID][k]["toXCoord"],Seed.queue_atkp[cityID][k]["toYCoord"]) + '</td>';
	              else m += '<TD style="padding-right:10px;">'+ cityTo +'</td>';      
	              if (knight != null)  m += '<TD width=20px><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/221.jpg></td><TD>'+ knight +'</td>';       
	              else m += '<TD width=20px><img  width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/221.jpg></td><TD>---</td>';   
	              var types = {10:"grasslands",11:"lake",20:"forest",30:"hills",40:"mountain",50:"plains",54:"boss"};
	              if (Seed.queue_atkp[cityID][k]["toTileType"]!=51) {
						if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=1 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=3) var Tlevel = 1;
						if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=4 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=6) var Tlevel = 4;
						if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=7) var Tlevel = 7;
	              		m+='<TD><img height=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/buildings/'+types[Seed.queue_atkp[cityID][k]["toTileType"]]+'_lvl'+Tlevel+'.png></td><TD>' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
	              } else {
	              	if (Seed.queue_atkp[cityID][k]["botSettingsId"]!=null){
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=1 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=3) var Tlevel = 1;
						if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=4 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=6) var Tlevel = 4;
						if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=7) var Tlevel = 7;
	              		m+='<TD><img height=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/buildings/barbarian_lvl'+Tlevel+'.png></td><TD>' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';         	 
	              	 }else {
	              	 	if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=1 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=2) var Tlevel = 1;
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=3 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=4) var Tlevel = 3;
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=5 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=6) var Tlevel = 5;
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=7 && Seed.queue_atkp[cityID][k]["toTileLevel"]<=9) var Tlevel = 7;
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]=10) var Tlevel = 10;
	              		if (Seed.queue_atkp[cityID][k]["toTileLevel"]>=11) var Tlevel = 11;
	              	 	m+='<TD><img height=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/buildings/castle_lvl'+Tlevel+'_26.png></td><TD>' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
	              	}
	              }
	              if (Seed.queue_atkp[cityID][k]["gold"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/gold_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["gold"]) +'</td>';
                // if (Seed.queue_atkp[cityID][k]["resourse4"] > 0) m += '<TD width=25px><img width=25px src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource4"]) +'</td>';
	              if (Seed.queue_atkp[cityID][k]["resource1"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/food_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource1"]) +'</td>';
	              if (Seed.queue_atkp[cityID][k]["resource2"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/wood_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource2"]) +'</td>';
	              if (Seed.queue_atkp[cityID][k]["resource3"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/stone_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource3"]) +'</td>';
	              if (Seed.queue_atkp[cityID][k]["resource4"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/iron_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource4"]) +'</td>';
                if (Seed.queue_atkp[cityID][k]["resource5"] > 0) m += '<TD width=25px><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/aetherstone_30.png></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["resource5"]) +'</td>';
               
                
                
	              
	              for(i=1; i<=17; i++){
	            if(Seed.queue_atkp[cityID][k]["unit"+i+"Count"] > 0 && type == "going") m += '<TD width=25px><a class=hasTooltip><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545><SPAN>'+unsafeWindow.unitcost['unt'+i][0]+'</span></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["unit"+i+"Count"]) +'</td>';
	            if(Seed.queue_atkp[cityID][k]["unit"+i+"Return"] > 0 && type == "returning") m += '<TD width=25px><a class=hasTooltip><img width=25px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545><SPAN>'+unsafeWindow.unitcost['unt'+i][0]+'</span></td><TD>'+ addCommas(Seed.queue_atkp[cityID][k]["unit"+i+"Return"]) +'</td>';
	          }
	          m += '</tr>';
	        }
	          }
    	}
    	m += '</table></div>';
    	document.getElementById('marchesBody').innerHTML = m;
    	for (var c=0; c< Seed.cities.length;c++) if (Seed.queue_atkp['city' + Seed.cities[c][0]].length !=0) for (k in Seed.queue_atkp['city' + Seed.cities[c][0]]) t.PaintSacrifice(k,c);
	},
	PaintSacrifice: function(k,c){
		var marchID = new String(k);
	    var now = unixTime();
	    marchID = marchID.substr(1);
	    skull_black="";
		skull_green="";
		skull_red="";	
	    var marchType = parseInt(Seed.queue_atkp['city' + Seed.cities[c][0]][k]["marchType"]);
	    var marchStatus = parseInt(Seed.queue_atkp['city' + Seed.cities[c][0]][k]["marchStatus"]);
	    
	    if (Seed.cityData.city[Seed.cities[c][0]].isPrestigeCity && Seed.cityData.city[Seed.cities[c][0]].prestigeInfo.prestigeType ==2 && Seed.queue_atkp['city' + Seed.cities[c][0]][k]["destinationUnixTime"] > now && marchType==4) document.getElementById("skull" + marchID).innerHTML = '<A onclick="button_sacrifice('+ marchID+','+ Seed.cities[c][0] +')"><img src="'+skull_black+'"></a>';
	},
	doSacrificeQ:function(marchID,city){
		paintS = new pbPopup ('pbSacrifice', 50, 50, 350, 200, true);
		paintS.centerMe (document.getElementById('marchesBody'));
		paintS.getMainDiv().innerHTML = '<DIV id=SacrificeBody style="height:180px; max-height:180px; width:350px; max-width:350px; overflow:auto">';
		paintS.getTopDiv().innerHTML = "<CENTER><b>Sacrifice</b></center>";
		paintS.show(true);

		var m ='<TABLE><TR>';

		for (var i=1;i<=16;i++){
			if (i%5==0) m+= '</tr><TR>';
			if (parseInt(Seed.queue_atkp['city' + city]['m'+marchID]['unit'+i+'Count'])>0) m+='<TD><INPUT type=checkbox id="SacrificeTroop_'+i+'"></td><TD style="width: 50px;"><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ i +'_30.jpg?6545></td>';
		}
		m+='</tr></table><BR><DIV vertical-align=center><INPUT id=DoSacrifice type=submit class=pbButton value="Sacrifice"></div>';
		document.getElementById('SacrificeBody').innerHTML = m;
	},
	butcancelmarch: function(marchID){
         var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
         params.mid = marchID;
         for (var c=0; c<Cities.numCities; c++){
           var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
           if (matTypeof(que)=='array') continue;
           for (k in que){
             if (k == 'm'+marchID){
               params.cid = Cities.cities[c].id;
               break;
             }
           }    
         }    
         new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelMarch.php" + unsafeWindow.g_ajaxsuffix, {
             method: "post",
             parameters: params,
             onSuccess: function (rslt) {
             var march = unsafeWindow.seed.queue_atkp["city" + params.cid]["m" + params.mid];
             march.marchStatus = 8;
              var marchtime = parseInt(march.returnUnixTime) - parseInt(march.destinationUnixTime);
              var ut = unixTime();
              if (unsafeWindow.seed.playerEffects.returnExpire > unixTime()) marchtime *= 0.5
               march.returnUnixTime = ut + marchtime;
               march.destinationUnixTime = ut;
               march.marchUnixTime = ut - marchtime;
               if (notify != null) notify(rslt.errorMsg);
             },
             onFailure: function () {
               if (notify != null) notify(rslt.errorMsg);
             },
         });
         
     },
     isMyself: function(userID){
		if(!Seed.players["u"+userID]) return false;
		if(Seed.players["u"+userID].n == Seed.player.name) return true;
		else return false;
		return false;
	},   
	butRecall : function (marchId){
    	var t = OutgoingMarches;
    	logit ("CANCELLING: "+ marchId); 
    	t.ajaxRecall(marchId); 
  	},
  	ajaxRecall : function (marchId, notify){
	    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	    for (var c=0; c<Cities.numCities; c++){
	      var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
	      if (matTypeof(que)=='array') continue;
	      for (k in que){
	        if (k == 'm'+marchId){
	          params.cid = Cities.cities[c].id;
	          break;
	        }
	      }    
	    }    
	    params.mid = marchId;
	    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/undefend.php" + unsafeWindow.g_ajaxsuffix, {
	        method: "post",
	        parameters: params,
	        onSuccess: function (rslt) {
	          var march = unsafeWindow.seed.queue_atkp["city" + params.cid]["m" + params.mid];
	          march.marchStatus = 8;
	          var marchtime = parseInt(march.returnUnixTime) - parseInt(march.destinationUnixTime);
	          var ut = unixTime();
	          if (unsafeWindow.seed.playerEffects.returnExpire > unixTime()) marchtime *= 0.5
	          march.returnUnixTime = ut + marchtime;
	          march.destinationUnixTime = ut;
	          march.marchUnixTime = ut - marchtime;
	          if (notify != null) notify(rslt.errorMsg);
	        },
	        onFailure: function () {
	          if (notify != null) notify(rslt.errorMsg);
	        },
	    });
  	},
	close: function(){OutgoingMarches.active=false}

}


var IncomingMarches = {
	active:false,	
	init: function(){
		var t = IncomingMarches;
    	unsafeWindow.button_sacrifice = t.doSacrificeQ;
		paintI = new pbPopup ('pbImarches', 50, 50, 750, 450, true, IncomingMarches.close);
		paintI.centerMe (mainPop.getMainDiv);
		paintI.getMainDiv().innerHTML = '<DIV><DIV id=IncomingmarchesBody style="height:425px; max-height:425px	; max-width:750px; overflow:auto"></div>';
		paintI.getTopDiv().innerHTML = "<CENTER><b>Incoming Marches</b></center>";
		if (IncomingMarches.active){
			paintI.show(false);
			IncomingMarches.active=false;
		} else {
			paintI.show(true);
			IncomingMarches.active=true;
		}	
	},
	show: function(){
		var t = IncomingMarches;
		var updatemarch = Seed.queue_atkp;
		var m='<TABLE cellSpacing=10 class=pbTab>';
     	var now=unixTime();
     	for (var c=0; c< Seed.cities.length;c++) {
	        number=0; 
	        var Counter=0;
	        var check = true;
	        for (k in Seed.queue_atkinc) if (parseInt(Seed.queue_atkinc[k].toCityId) == Seed.cities[c][0] && (Seed.queue_atkinc[k].marchType==3 ||Seed.queue_atkinc[k].marchType==4)) Counter++;
	        if (Counter==0) check=false;
			if (check) m+= '<TR><TD colspan=5 style="background: #335577;" align=center><B><FONT color=white>' +Seed.cities[c][1]+': </font></b></td></tr>';
	        for (k in Seed.queue_atkinc) if (parseInt(Seed.queue_atkinc[k].toCityId) == Seed.cities[c][0]  && (Seed.queue_atkinc[k].marchType==3 ||Seed.queue_atkinc[k].marchType==4)) {
	        	number++;
	        	var attack = Seed.queue_atkinc[k];
	        	m += '<TR><TD>'+ number +'</td>';
				if (attack.marchType == 3) m+= '<TD width=25;><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/scouting.jpg></td>';
				if (attack.marchType == 4) m+= '<TD width=25;><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg></td>';
				m+='<TD width=25px><div id="I_skull'+attack.mid+'"></div></td>';
				m+='<TD><FONT color='+(((attack.arrivalTime-now)<30)?"red":"black")+'>'+timestr(attack.arrivalTime-now)+'</font></td>';
				m+='<TD><a class=hasTooltip>'+Seed.players['u'+attack.pid].n+'<SPAN><TABLE><TR><TD>Alliance: </td><TD>'+Seed.allianceNames['a'+Seed.players['u'+attack.pid].a];
				m+='</td><tr><TR><TD>Might: </td><TD>'+addCommas(Math.round(Seed.players['u'+attack.pid].m))+'</td></tr>';
				m+='<TR><TD>March Time:</td><TD>'+timestr(attack.arrivalTime-attack.departureTime)+'</td></tr></table></span></a></td>';
				if (attack.fromXCoord) m+='<TD>'+coordLink(attack.fromXCoord,attack.fromYCoord)+'</td>';
				else m+='<TD>???</td>';
				var Marshal = "---";
				if (Seed.leaders['city'+Seed.cities[c][0]].combatKnightId!=0) Marshal = Seed.knights['city'+Seed.cities[c][0]]['knt'+Seed.leaders['city'+Seed.cities[c][0]].combatKnightId].combat;
				if (attack.knt) m+='<TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/221.jpg></td><TD>'+attack.knt.cbt+'/'+Marshal+'</td>';
				 else m+='<TD><img width=20px src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/221.jpg></td><TD>???</td>';
				if (Seed.queue_atkinc[k]["unts"] == undefined) {
						msg +='<TR><TD>???</td></tr>'; 
				} else for (i=1;i<=16;i++) if (parseInt(attack["unts"]["u"+i]) > 0) m+='<TD width=25px><img src=http://www352.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+i+'_30.jpg?6545></td><TD width=80px>' + addCommas(parseInt(attack["unts"]["u"+i])) + '</td>';			
				m += '</tr>';

	        }

    	}
    	m += '</table></div>';
    	document.getElementById('IncomingmarchesBody').innerHTML = m;
		for (var m in Seed.queue_atkinc) t.PaintSacrifice(Seed.queue_atkinc[m].mid,Seed.queue_atkinc[m].toCityId);
	},
	PaintSacrifice: function(marchID,cityID){
	    var now = unixTime();
	    skull_black="";
		skull_green="";
		skull_red="";	
	    if (Seed.cityData.city[cityID].isPrestigeCity && Seed.cityData.city[cityID].prestigeInfo.prestigeType ==2 && Seed.queue_atkinc[marchID].destinationUnixTime > now) document.getElementById("skull" + marchID).innerHTML = '<A onclick="button_sacrifice('+ marchID+','+ cityID +')"><img src="'+skull_black+'"></a>';
	},
	doSacrificeQ:function(marchID,city){
		alert('Auto Sacrifice coming soon...');
		return;
		paintS = new pbPopup ('pbSacrifice', 50, 50, 200, 200, true);
		paintS.centerMe (document.getElementById('marchesBody'));
		paintS.getMainDiv().innerHTML = '<DIV id=SacrificeBody style="max-height:200px; max-width:200px; overflow:auto">';
		paintS.getTopDiv().innerHTML = "<CENTER><b>Sacrifice</b></center>";
		paintS.show(true);


		//alert(Seed.queue_atkp['city' + city]['m'+marchID].toSource());
		var m ='<TABLE><TR>';

		for (var i=1;i<=17;i++){
			if (i%5==0) m+= '</tr><TR>';
			if (parseInt(Seed.queue_atkp['city' + city]['m'+marchID]['unit'+i+'Count'])>0) m+='<TD style="width: 30px;"><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ i +'_30.jpg?6545></td><TD>' + Seed.queue_atkp['city' + city]['m'+marchID]['unit'+i+'Count'] + '</td>';
		}
		m+='</tr></table>';
		document.getElementById('SacrificeBody').innerHTML = m;
	},    
	close: function(){OutgoingMarches.active=false}
}


var QueueMarches = {
	active:false,	
	init: function(){
		var t = QueueMarches;
		paintQ = new pbPopup ('pbVmarches', 50, 50, 750, 450, true, QueueMarches.close);
		paintQ.centerMe (mainPop.getMainDiv);
		paintQ.getMainDiv().innerHTML = '<DIV><DIV id=QueuemarchesBody style="height:425px; max-height:425px	; max-width:750px; overflow:auto"></div>';
		paintQ.getTopDiv().innerHTML = "<CENTER><b>Queued Marches</b></center>";
		if (QueueMarches.active){
			paintQ.show(false);
			QueueMarches.active=false;
		} else {
			paintQ.show(true);
			QueueMarches.active=true;
		}	
	},
	show: function(){
		var t = QueueMarches;
		var updatemarch = Seed.queue_atkp;
		var m='Transport/DF/Attack/Farm/Crest use a central march system. This central march system makes a virtual queue.<BR>So every second a city looks if it can add an action to that virtual queue. Checks will be done in the above sequence.<BR>Every 5sec a city will send out a march from that virtual queue (making req. send out more even), so fighting captcha.';
		m+='<BR><TABLE cellSpacing=10 class=pbTab>';
     	var now=unixTime();
     	for (var c=1;c<=Seed.cities.length;c++) {
	        number=0; 
	        if (MarchQueue[c].length==0) var check=false;
	        else var check=true;
			if (check) m+= '<TR><TD colspan=5 style="background: #335577;" align=center><B><FONT color=white>' +Seed.cities[c-1][1]+': </font></b></td></tr>';
	        for (var i=0;i<MarchQueue[c].length;i++) {
	        	number++;
	        	m += '<TR><TD>'+ number +'</td>';
	        	switch(MarchQueue[c][i].action){
	        		case (1): m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/transporting.jpg"></td>';break;
	        		case (2): m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/reinforce.jpg"></td>';break;
	        		case (3): m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/scouting.jpg"></td>';break;
	        		case (4): m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg"></td>';break;
	        		case (5): m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/transporting.jpg"></td>';break;
	        		default: m+='<TD><img src="https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/attacking.jpg"></td>';break;
	        	}
	        	m+='<TD>'+((MarchQueue[c][i].what==undefined||MarchQueue[c][i].what=="Attack")?"Attack":MarchQueue[c][i].what)+' Tab</td>';
	        	m+='<TD>'+coordLink(parseInt(MarchQueue[c][i].targetX),parseInt(MarchQueue[c][i].targetY))+'</td>';
	        	for (var u=1;u<=17;u++){
	        		if (parseInt(MarchQueue[c][i][u])>0) m+='<TD style="width: 30px;"><img src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+ u +'_30.jpg?6545></td><TD>' + addCommas(parseInt(MarchQueue[c][i][u])) +'</td>';
	        	}
				m += '</tr>';

	        }

    	}
    	m += '</table></div>';
    	document.getElementById('QueuemarchesBody').innerHTML = m;
	},
	close: function(){QueueMarches.active=false}
}


//******************** Auto Update ***************************//

var AutoUpdater_162501 = {
    id: 162501,
    version: Version,
    call: function(secure) {
        GM_xmlhttpRequest({
            method: 'GET',
        url: 'http'+(secure ? 's' : '')+'://userscripts.org/scripts/source/'+this.id+'.meta.js',
        onload: function(xpr) {AutoUpdater_162501.compare(xpr);},
            onerror: function(xpr) {if (secure) AutoUpdater_162501.call(false);}
        });
    },
    compareVersion: function(r_version, l_version) {
    	r_version = r_version.substr(5);
    	l_version = l_version.substr(5);
        return (r_version !== l_version) ? r_version > l_version : false;
    },
    compare: function(xpr) {
        this.xversion=/\/\/\s*@version\s+(.+)\s*\n/i.exec(xpr.responseText);   
        if (this.xversion) this.xversion = this.xversion[1];
         else return; 
        var updated = this.compareVersion(this.xversion, this.version);   
        if (updated) {                  
 			var body = '<BR><DIV align=center><FONT size=3><B>New version ' + this.xversion + ' is available!</b></font></div><BR>';
 			body+='<BR><iframe style=";border:0;width:475px;max-width:475px;height:150px;max-height:150px;overflow:auto" src="http://nicodebelder.eu/koc/AIO_changelog.html"></iframe><BR>';
 			body+='<BR><DIV align=center><a class="gemButtonv2 green" id="doBotUpdate">Update</a></div>';
 			ShowUpdate(body);
        } 
    },
    check: function() {
    	var now = unixTime();
    	var lastCheck = 0;
    	if (localStorage.updated_162501) lastCheck = parseInt(localStorage.updated_162501);
		if (now > (lastCheck + 60*60*2)) this.call(true);
    }
};
setTimeout(function(){AutoUpdater_162501.check();},15000); 


function doBOTUpdate(){
	unsafeWindow.cm.ModalManager.closeAll();
	unsafeWindow.cm.ModalManager.close();
	var now = unixTime();
	localStorage.setItem ("updated_162501", now);
	location.href = 'http://userscripts.org/scripts/source/162501.user.js';
}

function ShowUpdate(body){
	var now = unixTime();	 
	unsafeWindow.cm.ModalManager.addMedium({
	    title: "Koc AIO Script",
	   	body: body,
	   	closeNow: false,
	    close: function () {
	    	localStorage.setItem ("updated_162501", now);
	    	unsafeWindow.cm.ModalManager.closeAll();
	    },
	    "class": "Warning",
		curtain: false,
        width: 500,
		height: 600,
		left: 140,
		top: 140
	});
	document.getElementById('doBotUpdate').addEventListener ('click', doBOTUpdate, false);   
}



/************ DEBUG WIN *************/
var debugWin = {
	popDebug:			null,
	dbDefaultNot:	'tech,tutorial,items,quests,wilderness,wildDef,buildings,knights,allianceDiplomacies,appFriends,players',
	dbSelect:			{},
	sortSeed:			[],
	sortNonSeed:	[],

	doit: function (){
		var t = debugWin;

		function syncBoxes (){
			for (var i=0; i<t.sortSeed.length; i++){
				var name = t.sortSeed[i];
				var box = document.getElementById('dbpop_'+name);
				box.checked = t.dbSelect[name];
			}
		}
		function clickedAll (){
			for (var k in t.dbSelect)
				t.dbSelect[k] = true;
			syncBoxes();
		}
		function clickedNone (){
			for (var k in t.dbSelect)
				t.dbSelect[k] = false;
			syncBoxes();
		}
		function clickedDefaults (){
			for (k in t.dbSelect)
				t.dbSelect[k] = true;
			var not = t.dbDefaultNot.split(',');
			for (var i=0; i<not.length; i++)
				t.dbSelect[not[i]] = false;
			syncBoxes();
		}
		function clickedShow (){
			var resultsDiv = document.getElementById('idDebugResultsDiv')
			var s = '<PRE>';
			for (var i=0; i<t.sortSeed.length; i++){
				var name = t.sortSeed[i];
				var box = document.getElementById('dbpop_'+name);
				if (box.checked)
					s += name + " =\n" + inspect (Seed[name], 10, 1);
			}
			resultsDiv.innerHTML = s + '</PRE>';
		}

		function clickedShowNonSeed (){
			var resultsDiv = document.getElementById('idDebugResultsDiv');
			nsvalue = document.getElementById('dbnonseed').value;
			if (nsvalue != '') {
				val = unsafeWindow[nsvalue];
				valtype = typeof(val);
				resultsDiv.innerHTML = '<PRE>(' + valtype + ') ' + nsvalue + ((valtype == 'string')?(" = " + val):(" =\n" + inspect (val, 10, 1))) + '</PRE>';
			}
		}

		function clickedShowScripts (){
			var resultsDiv = document.getElementById('idDebugResultsDiv')
			var scripts = document.getElementsByTagName('script');
			var s = '';
			for (var i=0; i<scripts.length; i++)
				if (scripts[i].src!=null && scripts[i].src!='')
					s+='<A TARGET=_tab HREF="'+ scripts[i].src +'">'+ scripts[i].src +'</A><BR />';
			resultsDiv.innerHTML = s;
		}

		if (t.popDebug == null){
			t.popDebug = new pbPopup ('db', 0, 45, 749, 900, true);
			t.popDebug.getTopDiv().innerHTML = '<DIV align=center><B>DEBUG</B></DIV>';
			var sl = 0;
			for (var k in Seed) {
				t.dbSelect[k] = true;
				t.sortSeed[sl] = k;
				sl++;
			}
			t.sortSeed.sort();
			sl = 0;
			for (var k in unsafeWindow) {
				kType = typeof(unsafeWindow[k]);
				if ((k.indexOf('actionlink_data') != 0) && (k != 'content') && (k != 'document') && (k.indexOf('feed') != 0) && (k.indexOf('frame') != 0) && (k != 'globalStorage') &&
					(k != 'g_mapObject') && (k != 'history') && (k != 'Modal') && (k != 'navigator') && (k != 'parent') && (k.indexOf('pb') != 0) && (k.indexOf('pt') != 0) && (k != 'seed') &&
					(k != 'self') && (k.indexOf('template_data') != 0) && (k != 'that') && (k != 'window') && (k != '_htmlElement') && (kType != 'function') && (kType != 'undefined')) {
					t.sortNonSeed[sl] = k;
					sl++;
				}
			}
			t.sortNonSeed.sort(function(x,y) {var a = String(x).toUpperCase(); var b = String(y).toUpperCase(); if (a > b) return 1; else if (a < b) return -1; else return 0;});
			var nsSelect = '<SELECT id="dbnonseed"><OPTION value="" ></option>';
			for (var i=0; i<t.sortNonSeed.length; i++)
				nsSelect += '<OPTION value="' + t.sortNonSeed[i] + '" >' + t.sortNonSeed[i] + '</option>';
			nsSelect += '</SELECT>';
			var not = t.dbDefaultNot.split(',');
			for (var i=0; i<not.length; i++)
				t.dbSelect[not[i]] = false;
			var m = '<DIV class=ptentry><B>Seed: </B><INPUT type=submit class=pbButton id=dbsuball value=ALL>&nbsp;<INPUT type=submit class=pbButton id=dbsubnone value=NONE>&nbsp;' +
				'<INPUT type=submit class=pbButton id=dbdefaults value=DEFAULTS>&nbsp;<INPUT type=submit class=pbButton id=dbsubdo value=SHOW>&nbsp;<INPUT type=submit class=pbButton id=dbsubscripts value=SCRIPTS><BR /><TABLE width=100%>';
			var cols = 5;
			var entries = t.sortSeed.length;
			var rows = parseInt (0.99 + entries / cols);
			for (var rowno=1; rowno<=rows; rowno++) {
				m += '<TR>';
				for (colno=1; colno<=cols; colno++) {
					var slvalue = rows*(colno-1)+rowno-1;
					m += ((slvalue < entries)?('<TD class=xtab><INPUT type=checkbox id="dbpop_'+t.sortSeed[slvalue]+'">&nbsp;'+t.sortSeed[slvalue]+'</TD>'):'<TD class=xtab></TD>');
				}
				m += '</TR>';
			}
			m += '</TABLE><B>Non-Seed: </B>' + nsSelect + '</DIV><DIV id="idDebugResultsDiv" style="width:738px; height:600px; max-height:600px; overflow-y:auto; white-space:pre-wrap;"></DIV>';
			t.popDebug.getMainDiv().innerHTML = m;
			document.getElementById('dbsuball').addEventListener('click', clickedAll, false);
			document.getElementById('dbsubnone').addEventListener('click', clickedNone, false);
			document.getElementById('dbdefaults').addEventListener('click', clickedDefaults, false);
			document.getElementById('dbsubdo').addEventListener('click', clickedShow, false);
			document.getElementById('dbsubscripts').addEventListener('click', clickedShowScripts, false);
			document.getElementById('dbnonseed').addEventListener('change', clickedShowNonSeed, false);
			syncBoxes();
		}
		t.popDebug.show (true);
	},
}
//********************* GLOBAL FUNCTIONS **********************//

function CheckFilter (uid){
	for (var i=0;i<Options.PlayerFilter.length;i++) if (Options.PlayerFilter[i]['uid'] == uid) return true;
	return false;
}
function translate (str) {return str;}

function IncomingCheck(){
	var Counter=0;
	for (k in Seed.queue_atkinc) if (Seed.queue_atkinc[k].marchType==3 || Seed.queue_atkinc[k].marchType==4) Counter++;
	if (Counter==0 || Seed.queue_atkinc=="") document.getElementById('pbIncomingButton').style.display = "none";
	 else document.getElementById('pbIncomingButton').style.display = "inline";
}

function ClearMarchQueue(action){
	for (var c=1;c<=Seed.cities.length;c++){
		do {
			var check = false;
			for (var i=0;i<MarchQueue[c].length;i++) if (((MarchQueue[c][i].what==undefined||MarchQueue[c][i].what=="Attack")?"Attack":MarchQueue[c][i].what)==action) {MarchQueue[c].splice(i,1);check=true;}
		} while (check);
	}
}

var SpamEvery  = {
  timer : null,
  spamtimer : 0,
  init : function (){
    if (!Options.spamconfig.aspam) return;
    if (Options.spamconfig.spammins < 1)
    Options.spamconfig.spammins = 1;
    SpamEvery.setEnable (Options.spamconfig.aspam);
  },
  setEnable : function (tf){
    var t = SpamEvery;
    clearTimeout (t.timer);
    if (tf)
      t.timer = setTimeout (t.count, 60*1000);
  },
  count : function (){
   var t = SpamEvery;
   t.spamtimer = Options.spamconfig.spammins;
   if(parseInt(t.spamtimer) < 60) t.spamtimer = 60;
   if (Options.spamconfig.atime > t.spamtimer) {
    Options.spamconfig.atime = 2;
    t.doit ();
   } else {
    Options.spamconfig.atime = (Options.spamconfig.atime + 1);
    SpamEvery.init ();
   }
   saveOptions ();
  },
  doit : function (){
    actionLog ('Spamming ('+ Options.spamconfig.spammins +' minutes expired)');
    sendChat ("/" + Options.spamconfig.spamstate + " " +  Options.spamconfig.spamvert);
    SpamEvery.init ();
  }
}

var GMTclock = {
  span : null,
  init : function (){
    this.span = document.createElement ('span');
    this.span.style.fontWeight = 'bold';
    document.getElementById('kochead_time').parentNode.appendChild (this.span);
  },
  everySecond : function (){
    var now = new Date();  
    now.setTime(now.getTime() + (now.getTimezoneOffset()*60000));
  	GMTclock.span.innerHTML = ' &nbsp; ('+ now.toLocaleFormat('%H:%M') +')';
  },
}

function actionLog (msg){
    Tabs.Options.log (msg);  
}

function doTrain (cityId, tut, gamble, unitId, num, notify){
  var time = unsafeWindow.modal_barracks_traintime(unitId, num);
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.cid = cityId;
  params.type = unitId;
  params.quant = num;
  params.items = tut;
  params.gambleId = gamble;

  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function(rslt) {
      if (rslt.ok) {
        for (var i = 1; i < 5; i++) {
      var resourceLost = parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(num);
      if(rslt.gamble) resourceLost = resourceLost*rslt.gamble[i];
          unsafeWindow.seed.resources["city" + cityId]["rec" + i][0] = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]) - resourceLost;
        }
        unsafeWindow.seed.citystats["city" + cityId].gold[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].gold[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][5]) * parseInt(num);
        unsafeWindow.seed.citystats["city" + cityId].pop[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].pop[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][6]) * parseInt(num);
        unsafeWindow.seed.queue_unt["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, null]);
        if (notify != null)
          setTimeout (function (){notify(null);}, 500);
      } else {
        if (notify != null){
          setTimeout (function (){notify(rslt.errorMsg);}, 500);
        }
      }
    },
    onFailure: function(o) {
      if (notify != null)
        notify(rslt.errorMsg);
    }
  });
}

function doDefTrain (cityId, siege, unitId, num, notify){
  var time = unsafeWindow.modal_walls_traintime(unitId, num);
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.cid = cityId;
  params.type = unitId;
  params.quant = num;
  params.items = siege;
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fortify.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) {
          unsafeWindow.seed.queue_fort["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, rslt.fortifyId]);
          if (notify != null)
            setTimeout (function (){notify(null);}, 500);
        } else {
          if (notify != null)
            setTimeout (function (){notify(rslt.errorMsg);}, 500);
        }
      },
      onFailure: function () {
        if (notify != null)
          notify(rslt.errorMsg);
      },
  });
}

function renderKabamPresetStats(slot){
	var StatEffects = [];
	var m="";
	for (var k in unsafeWindow.cm.thronestats.effects) StatEffects[k] = 0;
	for (var k in unsafeWindow.kocThroneItems){
		y = unsafeWindow.kocThroneItems[k];
    	for (var ii=0;ii<Seed.throne.slotEquip[slot].length;ii++) if(Seed.throne.slotEquip[slot][ii] == y.id) for (var i=1;i<=5;i++) {
		   id = y["effects"]["slot"+i]["id"];
		   tier = parseInt(y["effects"]["slot"+i]["tier"]);
		   level = y["level"];
		   p = unsafeWindow.cm.thronestats.tiers[id][tier];
		   Current = p.base + ((level * level + level) * p.growth * 0.5);
		   if (i<=parseInt(y.quality)) StatEffects[id] += Current
		}
	}
	for (k=1;k<StatEffects.length;k++) if (StatEffects[k] != 0) m+= StatEffects[k] + '% '+unsafeWindow.cm.thronestats["effects"][k]["1"]+ '<br>';
	if (document.getElementById('KabamPresetHover'+slot)) document.getElementById('KabamPresetHover'+slot).innerHTML = m;
	if (document.getElementById('KabamPresetHover_Chat'+slot)) document.getElementById('KabamPresetHover_Chat'+slot).innerHTML = m;
}

function renderLocalPresetStats(preset){
	var StatEffects = [];
	var m="";
	for (var k in unsafeWindow.cm.thronestats.effects) StatEffects[k] = 0;
	for (var k in ThroneOptions.Presets[preset]){
		if (ThroneOptions.Presets[preset][k]!=0) {
			y = unsafeWindow.kocThroneItems[ThroneOptions.Presets[preset][k]];
	    	for (var i=1;i<=5;i++) {
			   id = y["effects"]["slot"+i]["id"];
			   tier = parseInt(y["effects"]["slot"+i]["tier"]);
			   level = y["level"];
			   p = unsafeWindow.cm.thronestats.tiers[id][tier];
			   Current = p.base + ((level * level + level) * p.growth * 0.5);
			   if (i<=parseInt(y.quality)) StatEffects[id] += Current
			}
		}
	}
	for (k=1;k<StatEffects.length;k++) if (StatEffects[k] != 0) m+= StatEffects[k] + '% '+unsafeWindow.cm.thronestats["effects"][k]["1"]+ '<br>';
	return m;
}

function formatUnixTime (unixTimeString,format){
	var rtn = unsafeWindow.formatDateByUnixTime (unixTimeString);
	return rtn;
}

function getCityPrestige (cityId){
	return Seed.cityData.city[cityId].isPrestigeCity;
}

String.prototype.capitalize = function(){ 
  return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
}

String.prototype.stripTags = function(){ 
  return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
}

function getAbsoluteOffsets (e){
  ret = {left:0, top:0};
  while (e.offsetParent){
    if (e.style.position == 'absolute')
      break;
    ret.left += e.offsetLeft;
    ret.top += e.offsetTop;
    e = e.offsetParent;
  }      
  return ret;  
}

function htmlTitleLine (msg){
  return '<TABLE width=100% cellspacing=0><TR><TD style="padding:0px" width=32%><HR></td><TD style="padding:0px"width=33%>[ '+ msg +' ]</td><TD style="padding:0px" width=32%><HR></td></tr></table>';  
}

function getDiplomacy (aid) {
  if(aid < 1 || aid == null) return 'unallianced';
  if (Seed.allianceDiplomacies == null) return 'neutral';
  if (Seed.allianceDiplomacies.friendly && Seed.allianceDiplomacies.friendly['a'+aid] != null) return 'friendly';
  if (Seed.allianceDiplomacies.hostile && Seed.allianceDiplomacies.hostile['a'+aid] != null) return 'hostile';
  if(getMyAlliance()[0] == aid) return 'ally';
  return 'neutral';
}

function getCityBuilding (cityId, buildingId){
  var b = Seed.buildings['city'+cityId];
  var ret = {count:0, maxLevel:0};
  for (var i=1; i<33; i++){
    if (b['pos'+i] && b['pos'+i][0] == buildingId){
      ++ret.count;
      if (parseInt(b['pos'+i][1]) > ret.maxLevel) ret.maxLevel = parseInt(b['pos'+i][1]);
    }
  }
  return ret;
}

function logit (msg){
  var now = new Date();
  GM_log (getServerId() +' @ '+ now.toTimeString().substring (0,8) +'.' + now.getMilliseconds() +': '+  msg);
}

function getWallInfo (cityId, objOut){
  objOut.wallSpaceUsed = 0;
  objOut.fieldSpaceUsed = 0;
  objOut.wallLevel = 0;  
  objOut.wallSpace = 0;     
  objOut.fieldSpace = 0;  
  var b = Seed.buildings["city" + cityId];
  if (b.pos1==null) return;  
  objOut.wallLevel = parseInt(b.pos1[1]);
  var spots = 0;
  for (var i=1; i<(objOut.wallLevel+1); i++) spots += (i * 500);
  objOut.wallSpace = spots;     
  objOut.fieldSpace = spots;     
  var fort = Seed.fortifications["city" + cityId];
  for (k in fort){
    var id = parseInt(k.substr(4));
    if (id<60) objOut.wallSpaceUsed += parseInt(unsafeWindow.fortstats["unt"+ id][5]) * parseInt(fort[k]);
    else objOut.fieldSpaceUsed += parseInt(unsafeWindow.fortstats["unt"+ id][5]) * parseInt(fort[k]);
  }
}

var kboxtime = 1;
function killbox () {
   kboxtime += 1;
   if(!Options.KMagicBox) return;
   if (kboxtime > 50) return;
   if (Number(unsafeWindow.seed.items.i599) == 0) return;
   if(!document.getElementById('modal_mmb')) setTimeout(killbox,100);
    else unsafeWindow.Modal.hideModal();  
};

function MakeBlocks(getX,getY,radius){
	var blocks = [];
	var xx=0;
	var yy=0;
	for (x=(getX-radius);x<=(getX+radius);x+=5) {
	   for (y=(getY-radius);y<=(getY+radius);y+=5) {
			xx=x;
			yy=y;
			if (x>750) xx-=750;
			if (y>750) yy-=750;
			if (x<0) xx+=750;
			if (y<0) yy+=750;
			blocks.push ("bl_" + xx + "_bt_" + yy);
		}
	}
	return blocks;
}

function MakeProvinceBlocks(getX,getY){
	var blocks = [];
	var xx=0;
	var yy=0;
	for (x=getX;x<=(getX+30);x+=5) {
	   for (y=getY;y<=(getY+30);y+=5) {
			xx=x;
			yy=y;
			blocks.push ("bl_" + xx + "_bt_" + yy);
		}
	}
	return blocks;
}


function marchTimeCalculator(troops, is_round_trip, items_applied, cityID, action,dist) {
    if(dist=="NaN" || dist==0) return "N/A";
    var speed = 99999;
    var total_troops = 0;
    items_applied = items_applied || {};
    for(var troop_type in troops) {
        if(!troops[troop_type].toString().match(/^\d+$/)) continue;
        var troop_number = parseInt(troops[troop_type]);
        if(troop_number <= 0) continue;
        total_troops += troop_number;
        var troop_speed = parseInt(unsafeWindow.unitstats["unt" + troop_type][3]);
        troop_speed *= (1 + 0.1 * parseInt(Seed.tech.tch11));
        if(unsafeWindow.cm.unitHorsedBenefit[troop_type]) troop_speed = troop_speed * (1 + 0.05 * parseInt(Seed.tech.tch12))
         else {
            troop_speed *= (1 + 0.05 * (parseInt(Seed.tech2.tch1) || 0));
            troop_speed *= unsafeWindow.cm.BlessingSystemModel.applyBlessing(unsafeWindow.cm.BlessingSystemModel.getBlessing().BLOOD_LUST, cityID, {speed: true});
        }
        if(troop_speed < speed) speed = troop_speed;
    }
    speed *= unsafeWindow.cm.BlessingSystemModel.applyBlessing(unsafeWindow.cm.BlessingSystemModel.getBlessing().FILL_THE_RANKS, cityID, {marchspeed: true});
    speed *= unsafeWindow.cm.BlessingSystemModel.applyBlessing(unsafeWindow.cm.BlessingSystemModel.getBlessing().REDUCE_FATIGUE, cityID, {}); 
    var throne67 = unsafeWindow.cm.ThroneController.effectBonus(67);  //March Speed
    var throne68, throne69, throne70, throne71, throne72;
    throne68 = throne69 = throne70 = throne71 = throne72 = 0;
    switch (action){
    	case 1: throne70 = unsafeWindow.cm.ThroneController.effectBonus(70);break; //Transport March Speed
    	case 2: throne69 = unsafeWindow.cm.ThroneController.effectBonus(69);break; //Reinforcement March Speed 
    	case 3: throne72 = unsafeWindow.cm.ThroneController.effectBonus(72);break; //Scout March Speed
    	case 4: throne68 = unsafeWindow.cm.ThroneController.effectBonus(68);break; //Attack March Speed
    	case 5: throne71 = unsafeWindow.cm.ThroneController.effectBonus(71);break; //Reassign March Speed
    }
    var throneBoost = throne67 + throne68 + throne69 + throne70 + throne71 + throne72;
    speed = speed * (1 + (throneBoost * 0.01));
    var gi = unsafeWindow.cm.guardianModalModel.getMarchBonus();
    var multiplier = 1 + (gi * 0.01);
    if(unsafeWindow.cm.WorldSettings.isOn("GUARDIAN_MARCH_EFFECT")) speed = speed * multiplier;
    var time = 0;
    if(0 == speed || 0 == total_troops) return "N/A"; 
    time = Math.ceil(dist * 6000 / speed);
    if(items_applied["57"] && Seed.items.i57 > 0) time = parseInt(time * 0.5);
     else if(items_applied["55"] && Seed.items.i55 > 0) time = parseInt(time * 0.75);  
    if(unsafeWindow.g_env !== "dev") time += 30;
    now = unixTime();        
    if(Seed.playerEffects.returnExpire >now) time = parseInt(time * 0.75);
    if(is_round_trip) time *= 2;    
    return timestr(time);
}

var messageNav = {
	init : function (){
		t = messageNav;
		t.MapFunc = new CalterUwFunc ('modal_maptile', [[/}\s*$/, ';setTimeout(function() { MapAddon_hook(l, o, p, k, m, n, f, s, v, i, c, a, e, r, b, h, q, j, d, g); },0); }']]);
		unsafeWindow.MapAddon_hook = t.AddExtra;
		t.MapFunc.setEnable (true);
		t.MsgButtons = new CalterUwFunc ('modal_messages', [[/}\s*$/, ';setTimeout(function() { AddMsgButtons(); },0); }']]);
		unsafeWindow.AddMsgButtons = t.AddMsgButtons;
		t.MsgButtons.setEnable (true);
		t.CityButton = new CalterUwFunc ('citysel_click', [[/}\s*$/, ';setTimeout(function() { CityAddons(); },0); }']]);
		unsafeWindow.CityAddons = t.CityAddons;
		t.CityButton.setEnable (true);

	},
	setEnable : function (tf){},
	isAvailable : function (){
		t = messageNav;
		return t.mmFunc.isAvailable();
	},
	CityAddons: function  (){	
		for (i=0;i<Seed.cities.length;i++){
			if (Seed.cities[i][0] == unsafeWindow.currentcityid) Options.ReturnToCity = (i+1);
			saveOptions();
			color = "black";
			cityID = Seed.cities[i][0];
			if (Seed.cityData.city[cityID].isPrestigeCity) {
				if (Seed.cityData.city[cityID].prestigeInfo.prestigeType) {
					switch (parseInt(Seed.cityData.city[cityID].prestigeInfo.prestigeType)){
		    			case 1: color = "#689C00";break;
		    			case 2: color = "#E36600";break;
		    			case 3: color = "#A944DB";break;
		    		}
		    	}
			}
			document.getElementById('mod_citylist').children[i].innerHTML = "<SPAN><FONT fontFamily='georgia,​arial,​sans-serif' font-weight=700 font-size=11px color="+color+">"+ unsafeWindow.roman[i] +"</font></span>";
		}
		PaintStartUpQueue(unsafeWindow.currentcityid);
		if (Tabs.build.buildPop && Tabs.build.popupCity!=unsafeWindow.currentcityid) Tabs.build.buildPop.show (false);
	},
	AddMsgButtons :function() {
		t = messageNav;
		msgBody = document.getElementsByClassName('messageDeletes')[0];
		var a = document.createElement('a');
			a.className='buttonDown20 GiftReport';
			a.innerHTML='<span>Delete Gift Report</span>';
			a.addEventListener('click', function(){t.checkinbox(1);}, false);
		var div = document.createElement('span');
		msgBody = document.getElementsByClassName('messageDeletes')[0];
		var b = document.createElement('a');
			b.className='buttonDown20';
			b.innerHTML='<span>Send to Mail</span>';
			b.addEventListener('click', function(){t.checkinbox(2);}, false);
		var div = document.createElement('span');
		div.appendChild(a);
		div.appendChild(b);
		msgBody.appendChild(div);
	},
	checkinbox : function(what){
		var t = messageNav;
    	var body = document.getElementById('tbl_messages');
    	var trs=body.getElementsByTagName('tr');
    	var reports = [];
		for(var i=0; i<trs.length; i++){
			var tds = trs[i].getElementsByTagName('td');
			for(var j=0; j<tds.length; j++){
				if(tds[j].className == 'chkcol') var checkbox = tds[j];
				if(tds[j].className == 'dtcol') var date = tds[j];	
				if(tds[j].className == 'nmcol') var sender = tds[j];	
				if(tds[j].className == 'subjcol') var subject = tds[j];	
			}
			reports.push({checkbox:checkbox,date:date,sender:sender,subject:subject});
		}
		if (what==1) t.parseGiftReport(reports);
		if (what==2) t.parseMailReport(reports);
	},
	parseGiftReport : function(rpts){
    	var t = messageNav;
    	for(var i=0; i<rpts.length; i++) if(rpts[i].subject.innerHTML.indexOf('New Gift Received!') >= 0 && rpts[i].sender.innerHTML.indexOf('Kingdoms Of Camelot') >= 0) rpts[i].checkbox.firstChild.checked = true;	
		unsafeWindow.messages_action("delete","tbl_messages"); 
  	},
  	parseMailReport : function(rpts){
    	var t = messageNav;
    	var send = [];
		var help = unsafeWindow.getSelectedMessages("tbl_messages");
		var array = help.split(',');
		for (var a=0;a<array.length;a++) 
	    	for(var i=0;i<rpts.length; i++) {
	    		var sender = rpts[i].sender.textContent || rpts[i].sender.innerText;
				var subject = rpts[i].subject.textContent || rpts[i].subject.innerText;
				var date = rpts[i].date.textContent || rpts[i].date.innerText;
	    		if (rpts[i].checkbox.innerHTML.indexOf(array[a]) >=0) send.push({id:array[a],date:date,sender:sender,subject:subject}); 
	    	}
	    for (var i=0;i<send.length;i++) setTimeout(t.messageBody,(i*5000),send[i]);
  	},
  	messageBody: function(send){
  		var t= messageNav;
  		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.pf=0;
		params.requestType="GET_MESSAGE_FOR_ID";
		params.messageId = send.id;
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt) {
				if (rslt) t.sendToMail(send,rslt.messageBody);
			},
			onFailure: function () {
			},
		}, false);
  	},
  	sendToMail: function(send,messageBody){
  		var t = messageNav;
  		messageBody = messageBody.replace(/custom-line-break/g,"<BR>");
  		var msg = '<BR>Date: ' + send.date;
  		msg += '<BR>From: ' + send.sender,
  		msg += '<BR>Subject: ' + send.subject;
  		msg += '<BR><BR>' + messageBody; 
  		var content = '<BODY><HTML>' + msg + '</html></body>';
  		var data = {};
    	data.Subject ='Forwarded Message ('+getServerId()+')';
    	data.Message = content; 
    	GM_xmlhttpRequest({
        	method: 'POST',
        	url: 'http://nicodebelder.eu/koc/mail.php',
        	headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',},
        	data: implodeUrlArgs(data),
        	onload: function (response) {alert(response.responseText);},
    	});
    	document.getElementById('inbox_chk_'+send.id).checked = false;
  	},
	AddExtra :function(l, o, p, k, m, n, f, s, v, i, c, a, e, r, b, h, q, j, d, g) {
		t = messageNav;
		//modal_maptile(i, h.tileid, h.tilename, h.xcoord, h.ycoord, h.pic, h.username, h.might, h.title, h.alliance, h.cities, h.province, h.type, h.status, h.level, h.allianceId, h.cityid, h.tileuserid, h.typename, h.mistedflag)
		//alert(l +'/'+ o+'/'+ p+'/'+ k+'/'+ m+'/'+ n+'/'+ f+'/'+ s+'/'+ v+'/'+ i+'/'+ c+'/'+ a+'/'+ e+'/'+ r+'/'+ b+'/'+ h+'/'+ q+'/'+ j+'/'+ d+'/'+ g)
		if (j!=null && j > 0) {
			var div = document.getElementById('contextMenu');
			var scr = document.createElement('div');
			scr.innerHTML= "<a class='buttonv2 red h20' id=addToMarchTab>Add To March Tab</a><a class='buttonv2 green h20' id=AutoScout>Auto Scout</a>";
			div.appendChild(scr);
			document.getElementById('addToMarchTab').addEventListener('click', function(){t.GoToMarchTab(k,m,unsafeWindow.currentcityid);}, false);
			document.getElementById('AutoScout').addEventListener('click', function(){t.AutoScout(k,m);}, false);
		}
		if (e=="city_mist"){
			var div = document.getElementById('contextMenu');
			var scr = document.createElement('div');
			scr.innerHTML= "<a class='buttonv2 red h20' id=viewMisted>View Misted Info</a>";
			div.appendChild(scr);
			document.getElementById('viewMisted').addEventListener('click', function(){t.SetBookmark(k,m,o);}, false);
		}
	},
	AutoScout :function(x,y) {
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.kid = 0;
		params.u3=1;
		params.cid=unsafeWindow.currentcityid;
    	params.type=3;
	    params.xcoord=x;
	    params.ycoord=y;
	    params.gold=0;
	    params.items = "";
	    for (var i=1;i<=5;i++) params['r'+i]=0;
    	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
              method: "post",
              parameters: params,
              loading: true,
              onSuccess: function (transport) {
                  var rslt = eval("(" + transport.responseText + ")");
                  if (rslt.ok) {
	                  var now = unixTime();
	                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                  var ut = unixTime();
	                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	                  for(i = 0; i <= unitsarr.length; i++)if(params["u"+i])unitsarr[i] = params["u"+i];
	                  var resources=new Array();
	                  resources[0] = params.gold;
	                  for(i=1; i<=4; i++) resources[i] = params["r"+i];
	                  var currentcityid = params.cid;
	                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                  if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                  } else if (rslt.error_code ==8 || rslt.error_code ==3) t.AutoScout(x,y); 
              },
              onFailure: function () {}
      });     
	},
	GoToMarchTab :function(x,y,cityID) {
		mainPop.show (true);
		tabManager.e_clickedTab(null,"March");
		document.getElementById('MtargetX').value = x;
		document.getElementById('MtargetY').value = y;
		for (var t=0;t<Seed.cities.length;t++) if (parseInt(Seed.cities[t][0]) == cityID) var cityNum = t;
		document.getElementById('pbMfrom_'+cityNum).click(); 
	},
	SetBookmark:function(x,y,tileId){
		var t = messageNav;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="BOOKMARK_LOCATION";
		params.tileId=tileId;
    	params.bookmarkName = "Misted_City";	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) t.GetBookmarkInfo(x,y);	
      		},
    	});
	},
	GetBookmarkInfo:function(x,y){
		var t = messageNav;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="GET_BOOKMARK_INFO";	 
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {
      			var rslt = eval("(" + transport.responseText + ")");
        		if (rslt.ok) {
        			for (var i in rslt.bookmarkInfo) if (parseInt(rslt.bookmarkInfo[i].xCoord)==x && parseInt(rslt.bookmarkInfo[i].yCoord)==y) alert('Player: ' + rslt.bookmarkInfo[i].userName + ' - City Name: ' +  rslt.bookmarkInfo[i].cityName);	
        			t.RemoveBookMark(rslt.bookmarkInfo[i].bookmarkId);
        		}
      		},
    	});
	},
	RemoveBookMark:function(bookmarkId){
		var t = messageNav;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.requestType="REMOVE_BOOKMARK";
		params.bookmarkId=bookmarkId;
	    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/tileBookmark.php" + unsafeWindow.g_ajaxsuffix, {
      		method: "post",
      		parameters: params,
      		onSuccess: function (transport) {},
    	});
	},
}

var WatchDog ={
	Reports:{},
	init : function (){
	    var t = WatchDog;
		var saved = GM_getValue ('allianceRpt_'+getServerId());
	    if(saved!=null) t.Reports = JSON2.parse (saved);  
		else t.Reports = {};
	    //t.enable (Options.EnhanceAR);
  	},
  	FetchAllianceReports : function (){
		var t = WatchDog;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.group = "a";
		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (transport) {
				var rslt = eval("(" + transport.responseText + ")");
				t.parseAReports (rslt.arReports, rslt.arPlayerNames, rslt.arAllianceNames, rslt.arCityNames, rslt.totalPages);
			},
			onFailure: function (rslt) {},
		}, false);
  	},
	parseAReports : function (arReports, playerNames, allianceNames, cityNames, totalPages){
		var t = WatchDog;
		var myAllianceId = getMyAlliance()[0];
		var now = unixTime();
		var keys = unsafeWindow.Object.keys(arReports);
		if (matTypeof(arReports) != 'array'){
			for (var i = 0; i < keys.length; i++) {
				var report = arReports[keys[i]];
				report.side0AllianceId = parseInt(report.side0AllianceId);
				var targetDiplomacy = getDiplomacy (report.side0AllianceId);
				var diplomacy = getDiplomacy(report.side1AllianceId);
				//friendly
				if (report.side1AllianceId != myAllianceId){
					var ID = report.reportId;
					if(t.Reports["a"+ID] != null) return;
					  if (report.marchType == 3) atkType = 'Scout';
					  else if (report.marchType == 4) atkType = 'Attack';
					  if (report.side0TileType > 50) target = "city";
					  else if (report.side0TileType <= 50) target = "wild";
					  if(report.side1AllianceId == 0) var allianceName = 'Undefined';
					  else var allianceName = allianceNames["a"+report.side1AllianceId];
					var date=FullDateTime(report.reportUnixTime);
					var msg = ':::. Report No: '+report.reportId+' ('+timestr(now-report.reportUnixTime)+' ago) || || ';
					msg += atkType + ' on ' + playerNames['p'+report.side0PlayerId]+' ('+target+' at '+report.side0XCoord+','+report.side0YCoord+') | '+playerNames["p"+report.side1PlayerId]+' ('+report.side1XCoord+','+report.side1YCoord+') of '+allianceName+' ('+diplomacy+')';
					var send = true;
					if (!Options.WatchDogFilter && diplomacy=='friendly') send = false;
					if (send) sendChat('/a '+msg);
					t.SaveAllianceReport(report);
				}
			}
		}	  
	},
	SaveAllianceReport : function (rpt){
		t = WatchDog;
		var ID = rpt.reportId;
		t.Reports["a"+ID] = rpt.reportUnixTime;
		var now = unixTime() - (5*24*60*60);
		for(k in t.Reports) if(t.Reports[k] < now) delete t.Reports[k];	
		var string = JSON2.stringify(t.Reports);
		setTimeout(function() {GM_setValue("allianceRpt_"+getServerId(), string);}, 0);
	},
}

function getMaxLoad(unitType,unitCount) {
    var load = 0;
    var techLoadBoost = parseInt(Seed.tech.tch10) * 0.1;
    var unit_number = unitCount;
    var loadEffectBoost = 0;
    if (Seed.playerEffects.loadExpire > unixTime()) loadEffectBoost = 0.25
    var TRload = unsafeWindow.cm.ThroneController.effectBonus(6);
    if (unitType == 10 || unitType == 11 || unitType == 12) TRload += unsafeWindow.cm.ThroneController.effectBonus(59) ;
     else if (unitType == 7 || unitType == 8) TRload += unsafeWindow.cm.ThroneController.effectBonus(48);
	if (TRload > 500) TRload = 500;
    var loadBoost = (TRload * 0.01) + loadEffectBoost + techLoadBoost;
    load += unit_number * parseInt(unsafeWindow.unitstats['unt'+unitType][5]) * (1 + loadBoost);
    return (parseInt(load));
};

function distance (d, f, c, e) {
  	var a = 750;
  	var g = a / 2;
  	var b = Math.abs(c - d);
  	if (b > g) b = a - b;
  	var h = Math.abs(e - f);
  	if (h > g) h = a - h;
  	return Math.round(100 * Math.sqrt(b * b + h * h)) / 100;
};

var myServerId = null;
function getServerId() {
  if (myServerId == null) myServerId = parseInt(unsafeWindow.g_server);
  return myServerId;
}



function getMyAlliance (){
  if (Seed.allianceDiplomacies==null || Seed.allianceDiplomacies.allianceName==null) return [0, 'None'];
  else return [Seed.allianceDiplomacies.allianceId, Seed.allianceDiplomacies.allianceName];
}

function RefreshSeed(){
	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	
	new AjaxRequest(unsafeWindow.g_ajaxpath + "/fb/e2/src/main_src.php?g=&y=0&n=nan001&l=nl_NL&messagebox=&standalone=0&res=1&iframe=1&lang=en&ts=1304248288.7067&s=250&appBar=" + unsafeWindow.g_ajaxsuffix, {
	    method: "POST",
	    parameters: params,
	    onSuccess: function (rslt) {
	        var mainSrcHTMLCode = rslt.responseText;
	    	var myregexp = /var seed=\{.*?\};/;
	    	var match = myregexp.exec(mainSrcHTMLCode);
	    	if (match != null) {
	    		result = match[0];
	    		result = result.substr(4);
	    		var seed = eval(result);
	    		unsafeWindow.document.seed = seed;
	    		Seed = seed;
	    		unsafeWindow.seed = seed;
	    		updatebotbutton("Update OK :)", "pbSeedRefresh");
	    		setTimeout(function(){updatebotbutton('Refresh Seed', 'pbSeedRefresh')}, 5000);
	    	}
	    },
	    onFailure: function () {
	      if (notify != null)
	        notify(rslt.errorMsg);
	    },
	});
}

function RecallWatchdog(){
	var now = unixTime();
	if (Recall.length == 0) return;
	for (var i=0;i<Recall.length;i++) {
		var marchId = Recall[i].marchId;
		var arrivalTime = Recall[i].arrivalTime;
		if (Seed.queue_atkinc[marchId] == undefined && arrivalTime > now) {
			Recall.splice(i,1);
			if (SEND_ALERT_AS_WHISPER) sendChat ("/"+ Seed.player.name +' '+ "..:.| RECALLED ||  March with ID: " + marchId.substr(1)); // Whisper to myself
			else sendChat ("/a ..:.| RECALLED ||  March with ID: " + marchId.substr(1));   
		} else if (arrivalTime < now) Recall.splice(i,1);
	}
}

function FullDateTime(str){
 	var time = new Date(str*1000);
	D = addZero(time.getDate());
	M = addZero(time.getMonth()+1);
	Y = addZero(time.getFullYear());
	h = addZero(time.getHours());
	m = addZero(time.getMinutes());
	s = addZero(time.getUTCSeconds());
	var fullDate =  D +"/"+ M +"/"+ Y +"  "+ h + ":" + m + ":" + s;
	return fullDate;
}

function addZero(i){
	if (i<10) i="0" + i;	 
	return i;
}

function distance (d, f, c, e) {
  var a = 750;
  var g = a / 2;
  var b = Math.abs(c - d);
  if (b > g) b = a - b;
  var h = Math.abs(e - f);
  if (h > g) h = a - h;
  return Math.round(100 * Math.sqrt(b * b + h * h)) / 100;
}

function getKnights(cityId){
    var knt = new Array();
    for (k in Seed.knights['city' + cityId]){
           if (Seed.knights['city' + cityId][k]["knightStatus"] == 1 && Seed.leaders['city' + cityId]["resourcefulnessKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["politicsKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' + cityId]["combatKnightId"] != Seed.knights['city' + cityId][k]["knightId"] && Seed.leaders['city' +cityId]["intelligenceKnightId"] != Seed.knights['city' + cityId][k]["knightId"]){
               knt.push ({
                   Name:  	  Seed.knights['city' + cityId][k]["knightName"],
                   Combat:    parseInt(Seed.knights['city' + cityId][k]["combat"]),
                   ID:        Seed.knights['city' + cityId][k]["knightId"],
               });
           }
    }
    knt = knt.sort(function sort(a,b) {a = a['Combat'];b = b['Combat'];return a == b ? 0 : (a < b ? -1 : 1);});
    return knt; 
}

function getRallypoint(cityId){
	var rallypointlevel=0;
	for (var o in Seed.buildings["city" + cityId]){
	    var buildingType = parseInt(Seed.buildings["city" + cityId][o][0]);
	    var buildingLevel = parseInt(Seed.buildings["city" + cityId][o][1]);
	    if (buildingType == 12) rallypointlevel=parseInt(buildingLevel);
	}
	if (rallypointlevel == 12) rallypointlevel=11;
	if (Seed.cityData.city[cityId].isPrestigeCity && rallypointlevel>0) rallypointlevel += 3;
	return rallypointlevel;
}

function doMarch(action,WhatCity){
    var knight = getKnights(action.city);
	if (knight.toSource() == "[]") return;
	var kid = knight[0].ID;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    var TroopsOK = true;
    params.cid=action.city;
    params.type=action.action;
    if (action.action == 4 || action.action == 5) params.kid=kid;
    else params.kid=0;
    params.xcoord = action.targetX;
    params.ycoord = action.targetY;
    for (var i=1;i<=17;i++){
    	TroopsInCity = Seed.units['city'+action.city]['unt'+i];
    	if (action[i]) {
    		if (parseInt(TroopsInCity) < parseInt(action[i])) TroopsOK = false;
    		else if (parseInt(action[i]) > 0) params['u'+i]=action[i];
    	}

    }
    if (!TroopsOK) {
    	MarchOffset = MarchDelay;
    	return;
    }
    if (action.gold) params.gold = action.gold;
  	if (action.r1) params.r1= action.r1;
  	if (action.r2) params.r2= action.r2;
  	if (action.r3) params.r3= action.r3;
  	if (action.r4) params.r4= action.r4;
  	if (action.r5) params.r5= action.r5;
    
    var total=0;
	var maxsend = 0;
    var rallypointlevel = 0;	
    for (var o in Seed.buildings["city" + action.city]){
	    var buildingType = parseInt(Seed.buildings["city" + action.city][o][0]);
	    var buildingLevel = parseInt(Seed.buildings["city" + action.city][o][1]);
	    if (buildingType == 12) rallypointlevel=parseInt(buildingLevel);
	}
  	if(rallypointlevel == 11) rallypointlevel = 15;
	if(rallypointlevel == 12) rallypointlevel = 20;
  	maxsend = (rallypointlevel * 10000);
  	if (Seed.cityData.city[action.city].isPrestigeCity) {
  		switch(parseInt(Seed.cityData.city[action.city].prestigeInfo.prestigeLevel)){
  			case 1: maxsend = Math.round(maxsend * 1.50);break;
  			case 2: maxsend = Math.round(maxsend * 1.60);break;
  			case 3: maxsend = Math.round(maxsend * 1.65);break;
        case 4: maxsend = Math.round(maxsend * 1.70);break;
case 5: maxsend = Math.round(maxsend * 1.75);break;
case 6: maxsend = Math.round(maxsend * 1.80);break;
  		}
  	}
  	var TR = unsafeWindow.cm.ThroneController.effectBonus(66);
    if (TR > 150) TR=150;
  	maxsend += Math.round(maxsend * (TR / 100));
  	for (var i=1;i<=16;i++) total += parseInt(action[i]); 
  	if (total == 'Nan')	actionlog('City: ' + WhatCity + ' - Troops: ' + total);	
  	if (total == 0){
  		MarchQueue[WhatCity].splice(0,1);
  		MarchOffset = MarchDelay;
  		return;
  	}
  	
  	if (total > maxsend) MarchQueue[WhatCity].splice(0,1);	

      new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
              method: "post",
              parameters: params,
              loading: true,
              onSuccess: function (transport) {
                  var rslt = eval("(" + transport.responseText + ")");
                  if (rslt.ok) {
	                  MarchesSend++;
	                  var now = unixTime();
					  MarchQueue[WhatCity].splice(0,1);
					  MarchOffset = MarchDelay;
	                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                  var ut = unixTime();
	                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	                  for(i=0;i<=unitsarr.length;i++)if(params["u"+i]) unitsarr[i] = params["u"+i];	                      
	                  var resources=new Array();
	                  resources[0] = params.gold;
	                  for(i=1; i<=4; i++) resources[i] = params["r"+i];
	                  var currentcityid = params.cid;
	                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                  if(rslt.updateSeed) unsafeWindow.update_seed(rslt.updateSeed);
	                  if (params.type == 1) MakeTransportLog(params);
                  }
                  else {
                  	if (rslt.error_code !=8 && rslt.error_code !=3 && rslt.error_code != 104) actionLog("City: " + WhatCity + ' - ' + rslt.toSource());
                  	MarchesError++;        	
                  	switch (rslt.error_code){
                  		case 206: 
                  				//Cannot perform this action on target. Please try again later
                  				for (var k in Seed.wilderness['city'+action.city]) if (Seed.wilderness['city'+action.city][k]['xCoord']==CrestOptions.X && Seed.wilderness['city'+action.city][k]['yCoord']==CrestOptions.Y) Tabs.Crest.abandonWilderness(Seed.wilderness['city'+action.city][k]['tileId'],Seed.wilderness['city'+action.city][k]['xCoord'],Seed.wilderness['city'+action.city][k]['yCoord'],CrestOptions.CrestCity);
						      	MarchOffset = MarchDelay;
                  				break;
                  		case 213:
                  				//Unable to use target Knight. Knight must be in the City to be used. If you receive this message in error, please refresh the game
                  				MarchOffset = MarchDelay;
                  				break;
                  		case 104: 
                  				//Cannot perform this action on target location
                  				MarchQueue[WhatCity].splice(0,1);
                  				MarchOffset = MarchDelay;
                  				break;
             			case 0:
             					//Need to send at least one soldier", feedback:"Need to send at least one soldier
                  				MarchQueue[WhatCity].splice(0,1);
                  				MarchOffset = MarchDelay;
                  				break;
                  	}
                  	if (rslt.user_action == "marchCaptcha") {
                  		MarchOffset = 5*60; // 5 Minutes
                  		actionLog("CAPTCHA");
                  		document.getElementById('MarchesSendInfo').innerHTML += '&nbsp<FONT color=red><B>CAPTCHA</b></font>';
                  		//Captcha(params);
                  	}
                  	else MarchOffset = MarchDelay*2;
                  }
                  if (rslt.user_action != "marchCaptcha") {
                  	var m = '<TABLE class=pbTab><TR align=center><TD>Marches: <img src=""/>';
                  	m += "&nbsp" + MarchesSend + "&nbsp";
                  	m += '&nbsp - &nbsp<img src=""/>';
                  	m += "&nbsp" + MarchesError + '</td></tr></table>';
                  	document.getElementById('MarchesSendInfo').innerHTML =  m;
       			  }
              },
              onFailure: function () {}
      });             
}

function MakeTransportLog(what){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	params.blocks = "bl_" + what.xcoord + "_bt_" + what.ycoord;
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
  		method: "post",
  		parameters: params,
  		onSuccess: function (transport) {
  			var rslt = eval("(" + transport.responseText + ")");
    		if (rslt.ok) {
    			var userId = rslt.data["l_"+what.xcoord+"_t_"+what.ycoord].tileUserId;
				var targetCityName = rslt.data["l_"+what.xcoord+"_t_"+what.ycoord].cityName;
				var targetName = rslt.userInfo["u" + userId]["n"];
	    		for (var t=0;t<Seed.cities.length;t++) if (parseInt(Seed.cities[t][0]) == what.cid) var cityname = Seed.cities[t][1];
				var resources = 0;
			    if (what.gold) resources += parseInt(what.gold);
			   	if (what.r1) resources += parseInt(what.r1);
				if (what.r2) resources += parseInt(what.r2);
				if (what.r3) resources += parseInt(what.r3);
				if (what.r4) resources += parseInt(what.r4);
				if (what.r5) resources += parseInt(what.r5);
				var msg = "Transport: " + addCommas(resources) + " resources from " + cityname + " to: " + targetName + " (" + targetCityName + ')';
				actionLog(msg);
			}
  		},
	});	
}

function FillMarchQueue(){
	for (var ii=0;ii<Seed.cities.length;ii++){
		cityID = Seed.cities[ii][0];	
		var rallypointlevel = getRallypoint(cityID);
		var now = unixTime();
		if (Tabs.transport.traderState.running && (Options.lastCityTransport[ii+1]+(Options.transportinterval * 60)) < now) Tabs.transport.doMarch(cityID,ii);
		if (MarchQueue[ii+1].length < rallypointlevel) {
			 
      if (mercOptions.Running) var send = Tabs.merc.doMarch(cityID,ii);
      if (DFOptions.Running) var send = Tabs.DF.doMarch(cityID,ii);
			if (send) continue;
			if (AtkOptions.Running) Tabs.Attack.doMarch(cityID,ii);
			if (FarmOptions.Running) Tabs.farm.barbing(cityID,ii);
			if (CrestOptions.Running) {				
				for (var k in Seed.wilderness['city'+cityID]) if (Seed.wilderness['city'+cityID][k]['xCoord']==CrestOptions.X && Seed.wilderness['city'+cityID][k]['yCoord']==CrestOptions.Y) Tabs.Crest.abandonWilderness(Seed.wilderness['city'+cityID][k]['tileId'],Seed.wilderness['city'+cityID][k]['xCoord'],Seed.wilderness['city'+cityID][k]['yCoord'],CrestOptions.CrestCity);
				Tabs.Crest.FirstRound();
			}
		}
	}
}

function CheckMarchQueue(){
	var RP = getRallypoint(Seed.cities[WhatCity-1][0]);
	var MarchesRunning = CheckCityMarches(WhatCity-1);
	var total = 0;
	for (var i=1;i<=Seed.cities.length;i++) total += MarchQueue[i].length;
	if (total == 0) return;
	if (MarchQueue[WhatCity].length > 0) {
		if (MarchesRunning < (RP-Options.RPClip)) doMarch(MarchQueue[WhatCity][0],WhatCity);
		WhatCity++;
		if (WhatCity >= (Seed.cities.length+1)) WhatCity = 1;
	}
	else {
		WhatCity++;
		if (WhatCity >= (Seed.cities.length+1)) WhatCity = 1;
		CheckMarchQueue();
	}
}

function CheckCityMarches(City){
	var Counter=0;
	var cityID = Seed.cities[City][0];
	var now=unixTime();
	if (Seed.queue_atkp['city'+ cityID] != undefined) for (atkp in Seed.queue_atkp['city'+ cityID]) if (Seed.queue_atkp['city'+ cityID][atkp]["marchId"] || Seed.queue_atkp['city'+ cityID][atkp]["returnUnixTime"]>now) Counter++;
	return Counter;
}

function Captcha (params){
    captchawin = new pbPopup ('pbmarch_captcha', 0, 0, 400, 300, true);
    captchawin.centerMe (mainPop.getMainDiv);
    var m = "<CENTER><SPAN class=boldRed>CAPTCHA ALERT! You have been sending too many attacks!</span></center><br \>";
    m += "<CENTER><div class=\"captcha_container\"><form id=pbmarch_captchaform ></form></div></center>";
    captchawin.getMainDiv().innerHTML = m;
    captchawin.getTopDiv().innerHTML = "<CENTER><b>KOC AIO Script - March Captcha</b></center>";
    captchawin.show(true);
  
    unsafeWindow.Recaptcha.create("6LcT7cQSAAAAAG4whvbBz60hGjJg0ON1wRIRv_iD", "pbmarch_captchaform", {
        callback: function(){
            unsafeWindow.Recaptcha.focus_response_field();
            $("pbmarch_captchaform").addEventListener("submit", function(e){
                e.preventDefault();
                e.stopPropagation();
                params.marchWarning = 1;
                params.marchCaptcha_challenge = unsafeWindow.Recaptcha.get_challenge();
                params.marchCaptcha_response = unsafeWindow.Recaptcha.get_response();
				MarchOffset = MarchDelay;
                captchawin.destroy();
            }, false);
        },
        theme: "white"
    });
    return;
}

function GetFbToken (){
	document.getElementById('EmailFrame').innerHTML = '<IFRAME style="border:0;width:750px;max-width:750px;height:150px;max-height:150px;overflow:auto" src="http://nicodebelder.eu/koc/fb.html"></iframe>';
}



var AntiCheat = function () {
 	var x = document.getElementsByClassName('cmModalContainer guardian_generic undefined');
 	if(x.length > 0) for(y = 0; y < x.length;y++) if(String(x[y].innerHTML).indexOf('You have Kingdoms of Camelot open in a newer window') > -1) {actionLog('Refesh for Anti-Cheat :\'(');reloadKOC();}
}; 

function CoordClick(x,y){
	unsafeWindow.CloseChatMenu = CloseChatMenu;
	var menu = new pbPopup('pbMenu', cursorX, cursorY, 150, 192, true);
	var m = '<DIV style="max-height:170px; height:170px; overflow-y:auto" onmouseout="CloseChatMenu(event)">';
	m+= '<INPUT id=Chat_March type=submit class=buttonDash_OFF style="width: 145px;" value="Attack"><br>';
	m+= '<INPUT id=Chat_Scout type=submit class=buttonDash_OFF style="width: 145px;" value="Scout"><br>';
	m+= '<INPUT id=Chat_AutoScout type=submit class=buttonDash_OFF style="width: 145px;" value="AutoScout"><br>';
	m+= '<INPUT id=Chat_Transport type=submit class=buttonDash_ON style="width: 145px;" value="Transport"><br>';
	m+= '<INPUT id=Chat_Reinforce type=submit class=buttonDash_ON style="width: 145px;" value="Reinforce"><br>';
	m+= '<INPUT id=Chat_Reassign type=submit class=buttonDash_ON style="width: 145px;" value="Reassign"><br></div>';
	menu.getMainDiv().innerHTML = m;	
	document.getElementById('Chat_March').addEventListener('click', function(){menu.show(false);GoToMarchTab(x,y,4)}, false);
	document.getElementById('Chat_Scout').addEventListener('click', function(){menu.show(false);GoToMarchTab(x,y,3)}, false);
	document.getElementById('Chat_AutoScout').addEventListener('click', function(){menu.show(false);messageNav.AutoScout(x,y)}, false);
	document.getElementById('Chat_Transport').addEventListener('click', function(){menu.show(false);GoToTransportTab(x,y)}, false);
	document.getElementById('Chat_Reinforce').addEventListener('click', function(){menu.show(false);GoToMarchTab(x,y,2)}, false);
	document.getElementById('Chat_Reassign').addEventListener('click', function(){menu.show(false);GoToMarchTab(x,y,5)}, false);
	menu.getTopDiv().innerHTML = '<DIV align=center ><B>'+x+','+y+'</b></div>';
	menu.show(true);
	menu.div.style.top = (cursorY-20) +'px';
  	menu.div.style.left = (cursorX-35) + 'px';
  	unsafeWindow.cm.formatModel.jumpTo(x,y);
  	unsafeWindow.ChatMenu = menu;
}

function CloseChatMenu(e){
	var menu = document.getElementById('pbMenu_outer');
	var left = parseInt(menu.style.left.slice(0,-2));
	var width = parseInt(menu.style.width.slice(0,-2));
	var top = parseInt(menu.style.top.slice(0,-2));
	var height = parseInt(menu.style.height.slice(0,-2));
	var X = ((e.clientX > left && e.clientX < (left+width))?false:true);
	var Y = ((e.clientY > top && e.clientY < (top+height))?false:true);
	if (X || Y) unsafeWindow.ChatMenu.show(false);
}

function GoToMarchTab 	(x,y,action) {
	mainPop.show (true);
	tabManager.e_clickedTab(null,"March");
	document.getElementById('MtargetX').value = x;
	document.getElementById('MtargetY').value = y;
	document.getElementById('pbMarchType').value = action;
}

function GoToAttackTab 	(x,y) {
	mainPop.show (true);
	tabManager.e_clickedTab(null,"Attack");
	document.getElementById('targetX').value = x;
	document.getElementById('targetY').value = y;
}

function GoToTransportTab 	(x,y) {
	mainPop.show (true);
	tabManager.e_clickedTab(null,"transport");
	document.getElementById('ptcityX').value = x;
	document.getElementById('ptcityY').value = y;
}

var cursorX;
var cursorY;
document.onmousemove = function(e){cursorX = e.pageX;cursorY = e.pageY;Options.MouseMove=unixTime();}

function CheckForOtherScripts(){
	var list = document.getElementsByClassName("tab");
	var tools = false;
	var bot=false;
	for (var i = 0; i < list.length; i++) {
    		if (list[i].innerHTML.indexOf('TOOLS')>0) tools=true;
    		if (list[i].innerHTML.indexOf('BOT')>0) bot=true;
	}
	if (tools) alert('You seem to be running KOC Power Tools\nPlease disable it for best results!!');
	if (bot) alert('You seem to be running KOC Power BOT\nPlease disable it for best results!!');
}

function RemoveSummoningCircle(){
	var elem = document.getElementById('summoningCircleBanner');
	if (elem!=undefined && Options.pbSummonToggle) elem.style.display = "none";
}

function multiBrowserOverride(){
		//for (z =1;z<5;z++) {
			var x = document.getElementsByClassName('cmModalContainer guardian_generic undefined cmModal1');
			if(!x)
			var x = document.getElementsByClassName('cmModalContainer guardian_generic undefined cmModal2');
			if(!x)
			var x = document.getElementsByClassName('cmModalContainer guardian_generic undefined cmModal3');
			if(x)
				if(x.length > 0) {
					for(y = 0; y < x.length;y++) {
						if(String(x[y].innerHTML).indexOf("You have Kingdoms of Camelot open in a newer window. If you have multiple connections to the same world open, please use your most recent window for the best experience and close this one.") > -1){
							unsafeWindow.cm.ModalManager.close();
						}
					};
				}
			//}
		}

function eachSecond (){
	Seconds++;
	//Anti-Cheat check
	if (Seconds==2) multiBrowserOverride();
	if (Seconds%5==0) AntiCheat();
	//GMTclock
	//GMTclock.everySecond();
	//Alliance Report Watchdog
	if (Seconds%Options.WatchdogInterval==0 && Options.watchdog) WatchDog.FetchAllianceReports();
	//Overview Tab
	if (OverviewTabActive) Tabs.Overview.paintStats();
	//Outgoing Marches 
	if (OutgoingMarches.active) OutgoingMarches.show();  
	//Incoming Marches 
	if (IncomingMarches.active) IncomingMarches.show();
	IncomingCheck();  
	//March Queue
	if (QueueMarches.active) QueueMarches.show();
	//Show Player & Might in map.
	DrawLevelIcons();
	//Auto Build
	if (Seconds==2 && Tabs.build.buildStates.running == 'ON') Tabs.build.e_autoBuild();
	if (Seconds%20==0 && Tabs.build.buildStates.running == 'ON') Tabs.build.e_autoBuild();
	if (Seconds%20==0 && Tabs.build.buildStates.running == 'AUTO') Tabs.build.FullAuto();
	//Central March System
	FillMarchQueue();
	if (Seconds%MarchOffset==0) CheckMarchQueue();	
	// Dashboard Tab
	if (Seconds%2==0) Dashboard.RPM();
	if (Seconds%2==0 && DashboardOptions.showWarnings) Dashboard.CheckForAlerts();
	if (GlobalOptions.pbWideScreenStyle=="wide" || GlobalOptions.pbWideScreenStyle=="ultra") {
		if (DashboardOptions.showRP) Dashboard.ShowRP();
		if (DashboardOptions.showStatus) Dashboard.CityStatus();
		if (DashboardOptions.showTower) Dashboard.ShowTowerAlerts();
		if (Seconds%2==0 && DashboardOptions.showLog) Dashboard.ShowLog();
		if (DashboardOptions.showSacrifice) Dashboard.showSacrifice();
	}	
	// Tower Alert
	if (Seconds%2==0) Tabs.tower.eachSecond();
	if (Seconds%2==0) RecallWatchdog();
	//Paint Raids
	Tabs.Raid.paint();	
	// Chat Stuff
	if (Seconds%2==0) ChatPane.HandleChatPane();
	// Throne Room Timers
	if (Seconds%5==0)  Tabs.Throne.salvageCheck();
	if (Tabs.Throne.SalvageArray.length > 0 && Seconds%5==0) Tabs.Throne.doSalvage();
	if (ThroneOptions.Active && Seconds%10==0) Tabs.Throne.doAction();
	// Auto-delete Reports
	if (Seconds%120==0) DeleteReports.startdeletereports();
	if (Seconds == 10) DeleteReports.startdeletereports();
	//Auto Refresh Seed
	if (Seconds%300==0) RefreshSeed();
	//Check Gift
	if (Seconds==10) Tabs.Gift.Check();	
	//Food Alert
	if (Seconds%60==0) FoodAlerts.e_eachMinute();
  //overview
   if (Seconds==120) Tabs.overview.init();	
	//Apothecary Tab
	if (Seconds%30==0) Tabs.Apothecary.loop();
	//Crafting Tab
	if (CraftTabActive) Tabs.AutoCraft.PaintStats();
	if (Seconds%15==0 && CraftOptions.Running) Tabs.AutoCraft.CraftCylce();	
	//Get FB token for "Send to mail" app
	if (Seconds==2) GetFbToken();
	if (Seconds%3600==0) GetFbToken(); 

	if (Seconds==5) CheckForOtherScripts();
	document.getElementById('MouseMove').innerHTML = timestr(unixTime() - Options.MouseMove);
	//Remove Summoning Circle 
	if (Seconds==3) RemoveSummoningCircle();
  if (Seconds%8==0)  Tabs.AutoTrain.doAutoHour();
  
}

pbStartup();
